forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthenticate-union.test.js
More file actions
42 lines (37 loc) · 1.2 KB
/
Copy pathauthenticate-union.test.js
File metadata and controls
42 lines (37 loc) · 1.2 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
import { authResultType, authenticateError } from '../../objects/index'
import { authenticateUnion } from '../authenticate-union'
describe('given the authenticateUnion', () => {
describe('testing the field types', () => {
it('contains authResultType type', () => {
const demoType = authenticateUnion.getTypes()
expect(demoType).toContain(authResultType)
})
it('contains authenticateError type', () => {
const demoType = authenticateUnion.getTypes()
expect(demoType).toContain(authenticateError)
})
})
describe('testing the field selection', () => {
describe('testing the authResultType type', () => {
it('returns the correct type', () => {
const obj = {
_type: 'authResult',
authResult: {},
}
expect(authenticateUnion.resolveType(obj)).toMatchObject(authResultType)
})
})
describe('testing the authenticateError type', () => {
it('returns the correct type', () => {
const obj = {
_type: 'error',
code: 401,
description: 'text',
}
expect(authenticateUnion.resolveType(obj)).toMatchObject(
authenticateError,
)
})
})
})
})