-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathindex-test.js
44 lines (32 loc) · 1.18 KB
/
index-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as PolyfillFunctions from 'react-native/Libraries/Utilities/PolyfillFunctions';
jest.mock('react-native/Libraries/Utilities/PolyfillFunctions', () => ({
polyfillGlobal: jest.fn(),
}));
describe('Index', function () {
it('should apply Buffer polyfill', () => {
require('../index');
expect(PolyfillFunctions.polyfillGlobal).toBeCalledTimes(1);
expect(PolyfillFunctions.polyfillGlobal).toBeCalledWith(
'Buffer',
expect.any(Function),
);
});
it("shouldn't apply URL and URLSearchParams on import", () => {
expect(global.REACT_NATIVE_URL_POLYFILL).toBeUndefined();
require('../index');
expect(PolyfillFunctions.polyfillGlobal).toBeCalledTimes(1); // For Buffer
expect(global.REACT_NATIVE_URL_POLYFILL).toBeUndefined();
});
it('should export setupURLPolyfill', () => {
const imports = require('../index');
expect(imports.setupURLPolyfill).toBeDefined();
});
it('should export URL', () => {
const imports = require('../index');
expect(imports.URL).toBeDefined();
});
it('should export URLSearchParams', () => {
const imports = require('../index');
expect(imports.URLSearchParams).toBeDefined();
});
});