forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplete-tour-result.test.js
More file actions
49 lines (41 loc) · 1.45 KB
/
Copy pathcomplete-tour-result.test.js
File metadata and controls
49 lines (41 loc) · 1.45 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
import { GraphQLString } from 'graphql'
import { userPersonalType } from '../user-personal'
import { completeTourResult } from '../complete-tour-result'
describe('given the completeTourResult object', () => {
describe('testing the field definitions', () => {
it('has a status field', () => {
const demoType = completeTourResult.getFields()
expect(demoType).toHaveProperty('status')
expect(demoType.status.type).toMatchObject(GraphQLString)
})
it('has a user field', () => {
const demoType = completeTourResult.getFields()
expect(demoType).toHaveProperty('user')
expect(demoType.user.type).toMatchObject(userPersonalType)
})
})
describe('testing the field resolvers', () => {
describe('testing the status resolver', () => {
it('returns the resolved field', () => {
const demoType = completeTourResult.getFields()
expect(demoType.status.resolve({ status: 'status' })).toEqual('status')
})
})
describe('testing the user resolver', () => {
it('returns the resolved field', () => {
const demoType = completeTourResult.getFields()
const user = {
userName: 'user@test.com',
displayName: 'Test Account',
completedTours: [
{
tourId: 'tour1',
completedAt: new Date(),
},
],
}
expect(demoType.user.resolve({ user })).toEqual(user)
})
})
})
})