forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth-result.test.js
More file actions
55 lines (46 loc) · 1.63 KB
/
auth-result.test.js
File metadata and controls
55 lines (46 loc) · 1.63 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
import { GraphQLString } from 'graphql'
import { authResultType, userPersonalType } from '../index'
describe('given the auth result gql object', () => {
describe('testing field definitions', () => {
it('has an authToken field', () => {
const demoType = authResultType.getFields()
expect(demoType).toHaveProperty('authToken')
expect(demoType.authToken.type).toMatchObject(GraphQLString)
})
it('has a user field', () => {
const demoType = authResultType.getFields()
expect(demoType).toHaveProperty('user')
expect(demoType.user.type).toMatchObject(userPersonalType)
})
})
describe('testing the field resolvers', () => {
describe('testing the authToken resolver', () => {
it('returns the resolved field', () => {
const demoType = authResultType.getFields()
expect(demoType.authToken.resolve({ token: 'authToken' })).toEqual(
'authToken',
)
})
})
describe('testing the user field', () => {
it('returns the resolved field', () => {
const demoType = authResultType.getFields()
const user = {
userName: 'test.account@istio.actually.exists',
displayName: 'Test Account',
preferredLang: 'french',
tfaValidated: false,
emailValidated: false,
}
const expectedResult = {
userName: 'test.account@istio.actually.exists',
displayName: 'Test Account',
preferredLang: 'french',
tfaValidated: false,
emailValidated: false,
}
expect(demoType.user.resolve({ user })).toEqual(expectedResult)
})
})
})
})