-
Notifications
You must be signed in to change notification settings - Fork 126
/
routes.unit.spec.jsx
77 lines (70 loc) · 2.33 KB
/
routes.unit.spec.jsx
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
import backendServices from '@department-of-veterans-affairs/platform-user/profile/backendServices';
import { expect } from 'chai';
import sinon from 'sinon';
import { renderWithStoreAndRouter } from '@department-of-veterans-affairs/platform-testing/react-testing-library-helpers';
import reducer from '../../secure-messaging/reducers';
import routes from '../routes';
describe('MHV Secure Messaging Pilot environment routes', () => {
let oldLocation;
beforeEach(() => {
oldLocation = global.window.location;
delete global.window.location;
global.window.location = {
replace: sinon.spy(),
};
});
afterEach(() => {
global.window.location = oldLocation;
});
const noDowntime = {
scheduledDowntime: {
globalDowntime: null,
isReady: true,
isPending: false,
serviceMap: { get() {} },
dismissedDowntimeWarnings: [],
},
};
const initialState = {
featureToggles: [],
user: {
login: {
currentlyLoggedIn: true,
},
profile: {
services: [backendServices.MESSAGING],
},
},
...noDowntime,
};
it.skip('should redirect to the SM info page if the user is not whitelisted or the feature flag is disabled', () => {
const customState = { ...initialState };
customState.featureToggles[
`${'mhv_secure_messaging_cerner_pilot'}`
] = false;
customState.featureToggles[
`${'mhv_secure_messaging_to_va_gov_release'}`
] = true;
const { queryByText } = renderWithStoreAndRouter(routes, {
initialState: customState,
reducers: reducer,
path: `/`,
});
expect(queryByText('Messages', { selector: 'h1', exact: true }));
expect(window.location.replace.calledOnce).to.be.true;
});
it('should NOT redirect to the SM info page if the user is whitelisted or the feature flag is enabled', () => {
const customState = { ...initialState };
customState.featureToggles[`${'mhv_secure_messaging_cerner_pilot'}`] = true;
customState.featureToggles[
`${'mhv_secure_messaging_to_va_gov_release'}`
] = true;
const { queryByText } = renderWithStoreAndRouter(routes, {
initialState: customState,
reducers: reducer,
path: `/`,
});
expect(queryByText('Messages', { selector: 'h1', exact: true }));
expect(window.location.replace.calledOnce).to.be.false;
});
});