-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphql.test.js
More file actions
49 lines (42 loc) · 1.09 KB
/
graphql.test.js
File metadata and controls
49 lines (42 loc) · 1.09 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
const { cleanUp, callGQL } = require('../helpers/helpers.js');
const getAllItemsQuery = `
query {
getAllItems {
name
id
}
}
`;
const createItemMutation = `
mutation {
createItem(input: {
name: "Test Foo"
description: "Test Description Foo"
location: [{location: "Here"}]
status: INUSE
}) {
name
id
}
}
`;
describe('GraphQL API Tests', () => {
beforeEach(() => {
cleanUp();
});
afterAll(() => {
cleanUp();
});
it('should return no items for a valid getAllItems query against an empty collection', async () => {
var response = await callGQL(getAllItemsQuery);
expect(response.status).toBe(200);
expect(response.body.data.getAllItems).toHaveLength(0);
});
it('should be able to createItem and getAllItems and return one item', async () => {
var createResponse = await callGQL(createItemMutation);
expect(createResponse.status).toBe(200);
var getAllResponse = await callGQL(getAllItemsQuery);
expect(getAllResponse.status).toBe(200);
expect(getAllResponse.body.data.getAllItems).toHaveLength(1);
});
});