Skip to content

Commit b89c760

Browse files
committed
fix: properly scope test-specific mocks
1 parent 474f8e5 commit b89c760

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

__tests__/banner.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1+
import * as ReactNative from 'react-native';
12
import React from 'react';
23
import { render } from '@testing-library/react-native';
34
import { BannerAd, BannerAdSize } from '../src';
45

56
const MOCK_ID = 'MOCK_ID';
67

8+
jest.doMock('react-native', () => {
9+
return Object.setPrototypeOf(
10+
{
11+
...ReactNative,
12+
Platform: {
13+
OS: 'android',
14+
select: () => {},
15+
},
16+
},
17+
ReactNative,
18+
);
19+
});
20+
721
describe('Google Mobile Ads Banner', function () {
822
it('throws if no unit ID was provided.', function () {
923
let errorMsg;

jest.setup.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import * as ReactNative from 'react-native';
33
jest.doMock('react-native', () => {
44
return Object.setPrototypeOf(
55
{
6-
Platform: {
7-
OS: 'android',
8-
select: () => {},
9-
},
106
NativeModules: {
117
...ReactNative.NativeModules,
128
RNAppModule: {

0 commit comments

Comments
 (0)