index.test.tsx
747 Bytes
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
import { InMemoryCache, gql } from '@apollo/client'
import React from 'react'
import Index from '../pages'
import renderer from 'react-test-renderer'
import { MockedProvider } from '@apollo/client/testing'
const cache = new InMemoryCache()
cache.writeQuery({
query: gql`
query Viewer {
viewer {
id
name
status
}
}
`,
data: {
viewer: {
__typename: 'User',
id: 'Baa',
name: 'Baa',
status: 'Healthy',
},
},
})
describe('Index', () => {
it('renders the html we want', async () => {
const component = renderer.create(
<MockedProvider cache={cache}>
<Index />
</MockedProvider>
)
expect(component.toJSON()).toMatchSnapshot()
})
})