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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
import actions from '../../../app/javascript/journey_patterns/actions'
const dispatch = function(){}
const currentPage = 1
describe('when receiveJourneyPatterns is triggered', () => {
it('should create an action to pass json to reducer', () => {
const json = undefined
const expectedAction = {
type: 'RECEIVE_JOURNEY_PATTERNS',
json
}
expect(actions.receiveJourneyPatterns()).toEqual(expectedAction)
})
})
describe('when previous navigation button is clicked', () => {
it('should create an action to go to previous page', () => {
const nextPage = false
const pagination = {
totalCount: 25,
perPage: 12,
page:1
}
const expectedAction = {
type: 'GO_TO_PREVIOUS_PAGE',
dispatch,
pagination,
nextPage
}
expect(actions.goToPreviousPage(dispatch, pagination)).toEqual(expectedAction)
})
})
describe('when next navigation button is clicked', () => {
it('should create an action to go to next page', () => {
const nextPage = true
const pagination = {
totalCount: 25,
perPage: 12,
page:1
}
const expectedAction = {
type: 'GO_TO_NEXT_PAGE',
dispatch,
pagination,
nextPage
}
expect(actions.goToNextPage(dispatch, pagination)).toEqual(expectedAction)
})
})
describe('when clicking on a journey pattern checkbox', () => {
it('should create an action to update journey pattern stop points', () => {
const event = {
currentTarget: {
id: '1'
}
}
const index = 1
const expectedAction = {
type: 'UPDATE_CHECKBOX_VALUE',
position: event.currentTarget.id,
index,
}
expect(actions.updateCheckboxValue(event, index)).toEqual(expectedAction)
})
})
describe('when clicking on next button', () => {
it('should create an action to open a confirm modal', () => {
const callback = function(){}
const expectedAction = {
type: 'OPEN_CONFIRM_MODAL',
callback
}
expect(actions.openConfirmModal(callback)).toEqual(expectedAction)
})
})
describe('when clicking on edit button', () => {
it('should create an action to open a edit modal', () => {
const index = 1
const journeyPattern = {}
const expectedAction = {
type: 'EDIT_JOURNEYPATTERN_MODAL',
index,
journeyPattern,
}
expect(actions.openEditModal(index, journeyPattern)).toEqual(expectedAction)
})
})
describe('when clicking on add button', () => {
it('should create an action to open a create modal', () => {
const expectedAction = {
type: 'CREATE_JOURNEYPATTERN_MODAL',
}
expect(actions.openCreateModal()).toEqual(expectedAction)
})
})
describe('when clicking on close button inside edit or add modal', () => {
it('should create an action to close modal', () => {
const expectedAction = {
type: 'CLOSE_MODAL',
}
expect(actions.closeModal()).toEqual(expectedAction)
})
})
describe('when clicking on a journey pattern delete button', () => {
it('should create an action to delete journey pattern', () => {
const index = 1
const expectedAction = {
type: 'DELETE_JOURNEYPATTERN',
index
}
expect(actions.deleteJourneyPattern(index)).toEqual(expectedAction)
})
})
describe('when changing on a journey pattern costs', () => {
it('should create an action to update journey pattern', () => {
const index = 1
const costs = {
"1-2": {
distance: 1
}
}
const expectedAction = {
type: 'UPDATE_JOURNEYPATTERN_COSTS',
index,
costs
}
expect(actions.updateJourneyPatternCosts(index, costs)).toEqual(expectedAction)
})
})
describe('when clicking on validate button inside edit modal', () => {
it('should create an action to save journey pattern modifications', () => {
const index = 1
const data = {}
const expectedAction = {
type: 'SAVE_MODAL',
index,
data
}
expect(actions.saveModal(index, data)).toEqual(expectedAction)
})
})
describe('when clicking on validate button inside create modal', () => {
it('should create an action to create a new journey pattern', () => {
const data = {}
const expectedAction = {
type: 'ADD_JOURNEYPATTERN',
data
}
expect(actions.addJourneyPattern(data)).toEqual(expectedAction)
})
})
describe('when submitting new journeyPatterns', () => {
it('should create an action to update pagination totalCount', () => {
const diff = 1
const expectedAction = {
type: 'UPDATE_TOTAL_COUNT',
diff
}
expect(actions.updateTotalCount(diff)).toEqual(expectedAction)
})
})
describe('when fetching api', () => {
it('should create an action to fetch api', () => {
const expectedAction = {
type: 'FETCH_API',
}
expect(actions.fetchingApi()).toEqual(expectedAction)
})
})
|