-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupJest.js
45 lines (39 loc) · 1.12 KB
/
setupJest.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
45
// Required to correctly polyfill React-Native
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
global.XMLHttpRequest = jest.fn();
global.fetch = jest.fn();
global.self = global;
if (typeof window !== 'object') {
global.window = global;
global.window.navigator = {};
}
import * as ReactNative from 'react-native';
jest.doMock('react-native', () => {
// Extend ReactNative
return Object.setPrototypeOf(
{
NativeModules: {
...ReactNative.NativeModules,
OktaSdkBridge: {
createConfig: jest.fn(),
signIn: jest.fn(),
signOut: jest.fn(),
getAccessToken: jest.fn(),
getIdToken: jest.fn(),
getUser: jest.fn(),
isAuthenticated: jest.fn(),
revokeAccessToken: jest.fn(),
revokeIdToken: jest.fn(),
revokeRefreshToken: jest.fn(),
introspectAccessToken: jest.fn(),
introspectIdToken: jest.fn(),
introspectRefreshToken: jest.fn(),
refreshTokens: jest.fn(),
},
},
},
ReactNative,
);
});