forked from warrenday/cypress-graphql-mock-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.spec.ts
53 lines (49 loc) · 1.08 KB
/
home.spec.ts
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
describe('Home Page', () => {
beforeEach(() => {
cy.readFile('./introspection.schema.graphql').then(schema => {
cy.mockNetwork({ schema });
});
cy.visit('http://localhost:3000');
});
it('displays initial list of todos', () => {
cy.mockNetworkAdd({
Query: () => ({
todos: () => ({
data: [
{
id: '1',
title: 'Go shopping',
completed: true,
},
{
id: '2',
title: 'Clean the house',
completed: false,
},
],
}),
}),
});
cy.get('li')
.eq(0)
.contains(/Go shopping/)
.should('exist');
cy.get('li')
.eq(1)
.contains(/Clean the house/)
.should('exist');
});
it('displays no todos message', () => {
cy.mockNetworkAdd({
Query: () => ({
todos: () => ({
data: [],
}),
}),
});
cy.get('li').should('have.length', 0);
cy.get('div')
.contains(/no todos found/)
.should('exist');
});
});