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 pathSection.test.jsx
More file actions
103 lines (95 loc) · 2.95 KB
/
Copy pathSection.test.jsx
File metadata and controls
103 lines (95 loc) · 2.95 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
import React from 'react'
import configureMockStore from 'redux-mock-store'
import { Provider } from 'react-redux'
import { MemoryRouter } from 'react-router'
import { mount } from 'enzyme'
// Use SF86 for now since it's a superset of all form sections.
// These tests should be moved into each component.
import { FLAT_SF86 } from 'config/formTypes'
import Section from './Section'
import { testSnapshot } from '../test-helpers'
// give a fake GUID so the field IDs don't differ between snapshots
// https://github.com/facebook/jest/issues/936#issuecomment-404246102
jest.mock('../Form/ValidationElement/helpers', () => (
Object.assign(require.requireActual('../Form/ValidationElement/helpers'), {
newGuid: jest.fn().mockReturnValue('MOCK-GUID'),
})
))
describe('The section component', () => {
const mockStore = configureMockStore()
it('is visible', () => {
const store = mockStore({
form: {},
application: {
Settings: {
formType: 'SF86',
},
},
})
const component = mount(
<MemoryRouter initialEntries={['/form/identification/intro']}>
<Provider store={store}>
<Section />
</Provider>
</MemoryRouter>,
)
expect(component.find('div').length > 0).toBe(true)
})
describe('renders', () => {
FLAT_SF86.forEach((section) => {
const store = mockStore({
authentication: {
authenticated: true,
token: 'fake-token',
},
section: {
subsection: section.name,
},
form: {
MILITARY_HISTORY: { data: { HasServed: { value: 'Yes' } } },
PSYCHOLOGICAL_COMPETENCE: { data: { IsIncompetent: { value: 'No' } } },
PSYCHOLOGICAL_CONSULTATIONS: { data: { Consulted: { value: 'No' } } },
PSYCHOLOGICAL_DIAGNOSES: { data: { Diagnosed: { value: 'No' } } },
PSYCHOLOGICAL_HOSPITALIZATIONS: { data: { Hospitalized: { value: 'No' } } },
},
application: {
Identification: {},
History: {},
Relationships: {},
Citizenship: {},
Military: {
History: {
HasServed: {
value: 'Yes',
},
},
},
Foreign: {},
Financial: {},
Substance: {},
Legal: {},
Psychological: {
Competence: { IsIncompetent: { value: 'No' } },
Consultations: { Consulted: { value: 'No' } },
Diagnoses: { Diagnosed: { value: 'No' } },
Hospitalizations: { Hospitalized: { value: 'No' } },
},
Settings: {
formType: 'SF86',
},
Errors: {},
Completed: {},
},
})
it(`${section.key}`, () => {
testSnapshot(
<Provider store={store}>
<MemoryRouter initialEntries={[section.fullPath]}>
<Section />
</MemoryRouter>
</Provider>,
)
})
})
})
})