This repository was archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathApplicationActions.test.js
More file actions
114 lines (109 loc) · 3.16 KB
/
ApplicationActions.test.js
File metadata and controls
114 lines (109 loc) · 3.16 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import {
updateIdentificationApplicantName,
updateIdentificationBirthPlace,
updateIdentificationBirthDate,
updateIdentificationSSN,
reportErrors,
clearErrors,
} from './ApplicationActions'
describe('Application actions', () => {
it('should create an action for updating identification properties', () => {
const tests = [
{
name: 'ApplicantName',
callback: () => updateIdentificationApplicantName('charles xavier'),
expected: {
type: 'Identification.ApplicantName',
section: 'Identification',
property: 'ApplicantName',
values: 'charles xavier',
},
},
{
name: 'ApplicantBirthPlace',
callback: () => updateIdentificationBirthPlace('Earth'),
expected: {
type: 'Identification.ApplicantBirthPlace',
section: 'Identification',
property: 'ApplicantBirthPlace',
values: 'Earth',
},
},
{
name: 'ApplicantBirthDate',
callback: () => updateIdentificationBirthDate('6/21/1982'),
expected: {
type: 'Identification.ApplicantBirthDate',
section: 'Identification',
property: 'ApplicantBirthDate',
values: '6/21/1982',
},
},
{
name: 'ApplicantSSN',
callback: () => updateIdentificationSSN('123456789'),
expected: {
type: 'Identification.ApplicantSSN',
section: 'Identification',
property: 'ApplicantSSN',
values: '123456789',
},
},
{
name: 'ApplicantNameReportError',
callback: () => {
const errors = [
{
code: 'minlength',
valid: false,
},
{
code: 'empty',
section: 'Identification',
subsection: 'Elsewhere',
valid: false,
},
]
return reportErrors('Identification', 'ApplicantName', errors)
},
expected: {
type: 'Errors.Identification',
section: 'Errors',
property: 'Identification',
values: [
{
code: 'minlength',
section: 'Identification',
subsection: 'ApplicantName',
valid: false,
},
{
code: 'empty',
section: 'Identification',
subsection: 'Elsewhere',
valid: false,
},
],
},
},
]
tests.forEach((t) => {
const actual = t.callback()
expect(actual.type).toEqual(t.expected.type)
expect(actual.section).toEqual(t.expected.section)
expect(actual.subsection).toEqual(t.expected.subsection)
expect(actual.property).toEqual(t.expected.property)
expect(actual.values).toEqual(t.expected.values)
})
})
it('creates an action to clear errors', () => {
const expectedAction = {
type: 'Errors.testProperty',
section: 'Errors',
property: 'testProperty',
subsection: 'testSection',
clear: true,
}
expect(clearErrors('testProperty', 'testSection')).toEqual(expectedAction)
})
})