@@ -4,9 +4,18 @@ import { describe, it, expect } from 'vitest';
4
4
import { ArrivalTimeTypes , StdcmStopTypes } from 'applications/stdcm/types' ;
5
5
import getStepLocation from 'modules/pathfinding/helpers/getStepLocation' ;
6
6
import {
7
+ resetStdcmConfig ,
7
8
stdcmConfInitialState ,
8
9
stdcmConfSlice ,
9
- stdcmConfSliceActions ,
10
+ updateGridMarginAfter ,
11
+ updateGridMarginBefore ,
12
+ updateMaxSpeed ,
13
+ updateStandardAllowance ,
14
+ updateStdcmConfigWithData ,
15
+ updateStdcmPathStep ,
16
+ updateTotalLength ,
17
+ updateTotalMass ,
18
+ updateTowedRollingStockID ,
10
19
} from 'reducers/osrdconf/stdcmConf' ;
11
20
import type { OsrdStdcmConfState , StandardAllowance , StdcmPathStep } from 'reducers/osrdconf/types' ;
12
21
import { createStoreWithoutMiddleware } from 'store' ;
@@ -82,7 +91,7 @@ describe('stdcmConfReducers', () => {
82
91
expect ( stateBefore . margins . standardAllowance ) . toBe ( initialTimeStandardAllowance ) ;
83
92
84
93
const newStandardAllowance = testDataBuilder . buildPercentageStandardAllowance ( 5 ) ;
85
- store . dispatch ( stdcmConfSliceActions . updateStandardAllowance ( newStandardAllowance ) ) ;
94
+ store . dispatch ( updateStandardAllowance ( newStandardAllowance ) ) ;
86
95
87
96
const stateAfter = store . getState ( ) [ stdcmConfSlice . name ] ;
88
97
expect ( stateAfter . margins . standardAllowance ) . toBe ( newStandardAllowance ) ;
@@ -91,23 +100,23 @@ describe('stdcmConfReducers', () => {
91
100
it ( 'should handle updateGridMarginBefore' , ( ) => {
92
101
const newGridMarginBefore = 5 ;
93
102
const store = createStore ( initialStateSTDCMConfig ) ;
94
- store . dispatch ( stdcmConfSliceActions . updateGridMarginBefore ( newGridMarginBefore ) ) ;
103
+ store . dispatch ( updateGridMarginBefore ( newGridMarginBefore ) ) ;
95
104
const state = store . getState ( ) [ stdcmConfSlice . name ] ;
96
105
expect ( state . margins . gridMarginBefore ) . toStrictEqual ( newGridMarginBefore ) ;
97
106
} ) ;
98
107
99
108
it ( 'should handle updateGridMarginAfter' , ( ) => {
100
109
const newGridMarginAfter = 5 ;
101
110
const store = createStore ( initialStateSTDCMConfig ) ;
102
- store . dispatch ( stdcmConfSliceActions . updateGridMarginAfter ( newGridMarginAfter ) ) ;
111
+ store . dispatch ( updateGridMarginAfter ( newGridMarginAfter ) ) ;
103
112
const state = store . getState ( ) [ stdcmConfSlice . name ] ;
104
113
expect ( state . margins . gridMarginAfter ) . toStrictEqual ( newGridMarginAfter ) ;
105
114
} ) ;
106
115
} ) ;
107
116
108
117
it ( 'should handle resetStdcmConfig' , ( ) => {
109
118
const store = createStore ( initialStateSTDCMConfig ) ;
110
- store . dispatch ( stdcmConfSliceActions . resetStdcmConfig ( ) ) ;
119
+ store . dispatch ( resetStdcmConfig ( ) ) ;
111
120
112
121
const state = store . getState ( ) [ stdcmConfSlice . name ] ;
113
122
expect ( state . rollingStockID ) . toBe ( stdcmConfInitialState . rollingStockID ) ;
@@ -138,7 +147,7 @@ describe('stdcmConfReducers', () => {
138
147
} ,
139
148
} as StdcmPathStep ;
140
149
store . dispatch (
141
- stdcmConfSliceActions . updateStdcmConfigWithData ( {
150
+ updateStdcmConfigWithData ( {
142
151
rollingStockID : 20 ,
143
152
stdcmPathSteps : [ parisStdcm , rennesStdcm ] ,
144
153
speedLimitByTag : 'new-tag' ,
@@ -154,23 +163,23 @@ describe('stdcmConfReducers', () => {
154
163
describe ( 'Consist updates' , ( ) => {
155
164
const store = createStore ( ) ;
156
165
it ( 'should handle totalMass' , ( ) => {
157
- store . dispatch ( stdcmConfSliceActions . updateTotalMass ( 345 ) ) ;
166
+ store . dispatch ( updateTotalMass ( 345 ) ) ;
158
167
const state = store . getState ( ) [ stdcmConfSlice . name ] ;
159
168
expect ( state . totalMass ) . toEqual ( 345 ) ;
160
169
} ) ;
161
170
162
171
it ( 'should handle totalLength' , ( ) => {
163
- store . dispatch ( stdcmConfSliceActions . updateTotalLength ( 345 ) ) ;
172
+ store . dispatch ( updateTotalLength ( 345 ) ) ;
164
173
const state = store . getState ( ) [ stdcmConfSlice . name ] ;
165
174
expect ( state . totalLength ) . toEqual ( 345 ) ;
166
175
} ) ;
167
176
it ( 'should handle maxSpeed' , ( ) => {
168
- store . dispatch ( stdcmConfSliceActions . updateMaxSpeed ( 110 ) ) ;
177
+ store . dispatch ( updateMaxSpeed ( 110 ) ) ;
169
178
const state = store . getState ( ) [ stdcmConfSlice . name ] ;
170
179
expect ( state . maxSpeed ) . toEqual ( 110 ) ;
171
180
} ) ;
172
181
it ( 'should handle towedRollingStockID' , ( ) => {
173
- store . dispatch ( stdcmConfSliceActions . updateTowedRollingStockID ( 11 ) ) ;
182
+ store . dispatch ( updateTowedRollingStockID ( 11 ) ) ;
174
183
const state = store . getState ( ) [ stdcmConfSlice . name ] ;
175
184
expect ( state . towedRollingStockID ) . toEqual ( 11 ) ;
176
185
} ) ;
@@ -191,7 +200,7 @@ describe('stdcmConfReducers', () => {
191
200
} ,
192
201
} ;
193
202
194
- store . dispatch ( stdcmConfSliceActions . updateStdcmPathStep ( { id : origin . id , updates } ) ) ;
203
+ store . dispatch ( updateStdcmPathStep ( { id : origin . id , updates } ) ) ;
195
204
const state = store . getState ( ) [ stdcmConfSlice . name ] ;
196
205
expect ( state . stdcmPathSteps . at ( 0 ) ) . toEqual ( { ...origin , ...updates } ) ;
197
206
} ) ;
@@ -204,7 +213,7 @@ describe('stdcmConfReducers', () => {
204
213
stopFor : 1 ,
205
214
} ;
206
215
207
- store . dispatch ( stdcmConfSliceActions . updateStdcmPathStep ( { id : via . id , updates } ) ) ;
216
+ store . dispatch ( updateStdcmPathStep ( { id : via . id , updates } ) ) ;
208
217
const state = store . getState ( ) [ stdcmConfSlice . name ] ;
209
218
expect ( state . stdcmPathSteps . at ( 1 ) ) . toEqual ( { ...via , ...updates } ) ;
210
219
} ) ;
@@ -221,7 +230,7 @@ describe('stdcmConfReducers', () => {
221
230
} ,
222
231
} ;
223
232
224
- store . dispatch ( stdcmConfSliceActions . updateStdcmPathStep ( { id : destination . id , updates } ) ) ;
233
+ store . dispatch ( updateStdcmPathStep ( { id : destination . id , updates } ) ) ;
225
234
const state = store . getState ( ) [ stdcmConfSlice . name ] ;
226
235
expect ( state . stdcmPathSteps . at ( - 1 ) ) . toEqual ( { ...destination , ...updates } ) ;
227
236
} ) ;
0 commit comments