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