-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathindex.test.tsx
89 lines (77 loc) · 1.93 KB
/
index.test.tsx
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import * as Msal from 'msal';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
require('jest-localstorage-mock'); // tslint:disable-line
import { AzureAD, LoginType } from './index';
import { MsalAuthProvider } from './MsalAuthProvider';
let Enzyme;
let Adapter;
let authProvider: MsalAuthProvider;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let testAccount: Msal.Account;
beforeAll(() => {
Enzyme = require('enzyme');
Adapter = require('enzyme-adapter-react-16');
Enzyme.configure({ adapter: new Adapter() });
});
beforeEach(() => {
// values stored in tests will also be available in other tests unless you run
localStorage.clear();
authProvider = new MsalAuthProvider(
{
auth: {
authority: 'https://login.microsoftonline.com/common',
clientId: '<guid>',
},
cache: {
cacheLocation: 'sessionStorage' as Msal.CacheLocation,
},
},
{
scopes: ['openid'],
},
{
loginType: LoginType.Popup,
},
);
testAccount = {
accountIdentifier: 'Something',
environment: 'testEnv',
homeAccountIdentifier: 'testIdentifier',
idToken: {},
idTokenClaims: {},
name: 'Lilian',
sid: 'sid',
userName: 'LilUsername',
};
});
it('renders without crashing', () => {
const unauthenticatedFunction = () => {
return (
<div>
<h1> unauthenticatedFunction </h1>
</div>
);
};
const authenticatedFunction = () => {
return (
<div>
<h1> authenticatedFunction </h1>
</div>
);
};
const accountInfoCallback = () => {
// empty
};
const div = document.createElement('div');
ReactDOM.render(
<AzureAD
provider={authProvider}
unauthenticatedFunction={unauthenticatedFunction}
authenticatedFunction={authenticatedFunction}
accountInfoCallback={accountInfoCallback}
/>,
div,
);
ReactDOM.unmountComponentAtNode(div);
});