-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhome.spec.ts
More file actions
75 lines (67 loc) · 1.47 KB
/
home.spec.ts
File metadata and controls
75 lines (67 loc) · 1.47 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
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');
});
it('displays a valid error', () => {
cy.mockNetworkAdd({
Query: {
todos: () => {
throw new Error('Oh dear');
},
},
});
cy.get('div')
.contains(/Oh dear/)
.should('exist');
});
it('disables the mock service', () => {
cy.mockNetworkStop();
cy.get('div')
.contains(/Request failed with status code 404/)
.should('exist');
});
});