forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrganizationDomains.test.js
More file actions
138 lines (129 loc) · 4.12 KB
/
OrganizationDomains.test.js
File metadata and controls
138 lines (129 loc) · 4.12 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import React from 'react'
import { render, waitFor } from '@testing-library/react'
import { MockedProvider } from '@apollo/client/testing'
import { MemoryRouter, Route } from 'react-router-dom'
import { theme, ThemeProvider } from '@chakra-ui/core'
import { UserVarProvider } from '../UserState'
import { PAGINATED_ORG_DOMAINS } from '../graphql/queries'
import { I18nProvider } from '@lingui/react'
import { setupI18n } from '@lingui/core'
import { OrganizationDomains } from '../OrganizationDomains'
import matchMediaPolyfill from 'mq-polyfill'
import { makeVar } from '@apollo/client'
const i18n = setupI18n({
locale: 'en',
messages: {
en: {},
},
localeData: {
en: {},
},
})
matchMediaPolyfill(window)
window
.matchMedia('(min-width: 920px)') // Create MediaQueryList instance
.addListener(console.log) // Subscribe to MQ mode changes
/**
* For dispatching resize event
* we must implement window.resizeTo in jsdom
*/
window.resizeTo = function resizeTo(width, height) {
Object.assign(this, {
innerWidth: width,
innerHeight: height,
outerWidth: width,
outerHeight: height,
}).dispatchEvent(new this.Event('resize'))
}
describe('<OrganizationDomains />', () => {
describe('given the url /organisations/tbs-sct-gc-ca', () => {
it('displays domains using the tbs-sct-gc-ca slug', async () => {
window.resizeTo(1024, 768)
const orgSlug = 'tbs-sct-gc-ca'
const mocks = [
{
request: {
query: PAGINATED_ORG_DOMAINS,
variables: { slug: 'tbs-sct-gc-ca', first: 10 },
},
result: {
data: {
findOrganizationBySlug: {
id: 'testid',
domains: {
pageInfo: {
hasNextPage: false,
endCursor: 'string',
hasPreviousPage: true,
startCursor: 'string',
},
edges: [
{
cursor: 'string',
node: {
id: 'OTUyNTQ3Mjg0Nw==',
domain: 'dfo-mpo.gc.ca',
lastRan: '1612768306050',
status: {
dkim: 'FAIL',
dmarc: 'FAIL',
https: 'INFO',
spf: 'FAIL',
ssl: 'PASS',
},
hasDMARCReport: true,
},
},
{
cursor: 'string',
node: {
id: 'ODEzNzA4ODA3OA==',
domain: 'dfait-maeci.gc.ca',
lastRan: '1612792126546',
status: {
dkim: 'PASS',
dmarc: 'PASS',
https: 'INFO',
spf: 'FAIL',
ssl: 'INFO',
},
hasDMARCReport: true,
},
},
],
},
},
},
},
},
]
const { getByText } = render(
<ThemeProvider theme={theme}>
<I18nProvider i18n={i18n}>
<MockedProvider mocks={mocks} addTypename={false}>
<UserVarProvider
userVar={makeVar({
jwt: null,
tfaSendMethod: null,
userName: null,
})}
>
<MemoryRouter
initialEntries={['/organization/tbs-sct-gc-ca']}
initialIndex={0}
>
<Route path="/organization/:orgSlug">
<OrganizationDomains orgSlug={orgSlug} />
</Route>
</MemoryRouter>
</UserVarProvider>
</MockedProvider>
</I18nProvider>
</ThemeProvider>,
)
await waitFor(() => {
expect(getByText('dfo-mpo.gc.ca')).toBeInTheDocument()
})
})
})
})