forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomainCard.test.js
More file actions
51 lines (47 loc) · 1.68 KB
/
DomainCard.test.js
File metadata and controls
51 lines (47 loc) · 1.68 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
import React from 'react'
import { render } from '@testing-library/react'
import { MemoryRouter } from 'react-router-dom'
import { ThemeProvider, theme } from '@chakra-ui/core'
import { I18nProvider } from '@lingui/react'
import { MockedProvider } from '@apollo/client/testing'
import { setupI18n } from '@lingui/core'
import { DomainCard } from '../DomainCard'
describe('<OrganizationsCard />', () => {
it('successfully renders card with domain name and date of last scan', async () => {
const { getByText } = render(
<MockedProvider>
<MemoryRouter initialEntries={['/']}>
<ThemeProvider theme={theme}>
<I18nProvider i18n={setupI18n()}>
<DomainCard
url="tbs-sct.gc.ca"
lastRan="2020-09-10T00:34:26.429Z"
/>
</I18nProvider>
</ThemeProvider>
</MemoryRouter>
</MockedProvider>,
)
const domain = getByText(/tbs-sct.gc.ca/i)
expect(domain).toBeDefined()
const lastRan = getByText(/2020-09-10T00:34:26.429Z/i)
expect(lastRan).toBeDefined()
})
it('presents appropriate message when no scan date is found', async () => {
const { getByText } = render(
<MockedProvider>
<MemoryRouter initialEntries={['/']}>
<ThemeProvider theme={theme}>
<I18nProvider i18n={setupI18n()}>
<DomainCard url="tbs-sct.gc.ca" lastRan={null} />
</I18nProvider>
</ThemeProvider>
</MemoryRouter>
</MockedProvider>,
)
const domain = getByText(/tbs-sct.gc.ca/i)
expect(domain).toBeDefined()
const lastRan = getByText(/Not scanned yet./i)
expect(lastRan).toBeDefined()
})
})