@@ -13,17 +13,18 @@ import {
13
13
setPlannerMaxYear ,
14
14
setPlannerIBLOCs ,
15
15
setIgnorePrerequisitesCheck ,
16
+ IMPORT_PLANNER ,
17
+ importPlanner ,
18
+ CLEAR_PLANNER ,
19
+ clearPlanner ,
16
20
} from 'actions/planner' ;
17
21
import { PlannerState } from 'types/reducers' ;
18
- import reducer , { migrateV0toV1 , nextId } from './planner' ;
22
+ import reducer , { defaultPlannerState , migrateV0toV1 , nextId } from './planner' ;
19
23
20
24
const defaultState : PlannerState = {
25
+ ...defaultPlannerState ,
21
26
minYear : '2017/2018' ,
22
27
maxYear : '2018/2019' ,
23
- iblocs : false ,
24
- ignorePrereqCheck : false ,
25
- modules : { } ,
26
- custom : { } ,
27
28
} ;
28
29
29
30
describe ( nextId , ( ) => {
@@ -203,6 +204,42 @@ describe(REMOVE_PLANNER_MODULE, () => {
203
204
} ) ;
204
205
} ) ;
205
206
207
+ describe ( IMPORT_PLANNER , ( ) => {
208
+ const initial : PlannerState = {
209
+ ...defaultState ,
210
+ } ;
211
+
212
+ const importedState : PlannerState = {
213
+ minYear : '2024/2025' ,
214
+ maxYear : '2025/2026' ,
215
+ iblocs : true ,
216
+ ignorePrereqCheck : true ,
217
+ modules : {
218
+ 0 : { id : '0' , moduleCode : 'CS1010S' , year : '2018/2019' , semester : 1 , index : 0 } ,
219
+ } ,
220
+ custom : {
221
+ CS1010A : { title : 'CS1010B' , moduleCredit : 4 } ,
222
+ } ,
223
+ } ;
224
+ test ( 'should import the given planner' , ( ) => {
225
+ expect ( reducer ( initial , importPlanner ( importedState ) ) ) . toEqual ( importedState ) ;
226
+ } ) ;
227
+ } ) ;
228
+
229
+ describe ( CLEAR_PLANNER , ( ) => {
230
+ const initial : PlannerState = {
231
+ ...defaultState ,
232
+
233
+ modules : {
234
+ 0 : { id : '0' , moduleCode : 'CS1010S' , year : '2018/2019' , semester : 1 , index : 0 } ,
235
+ } ,
236
+ } ;
237
+
238
+ test ( 'should clear the planner' , ( ) => {
239
+ expect ( reducer ( initial , clearPlanner ( ) ) ) . toEqual ( defaultPlannerState ) ;
240
+ } ) ;
241
+ } ) ;
242
+
206
243
describe ( migrateV0toV1 , ( ) => {
207
244
test ( 'should migrate old modules state to new modules state' , ( ) => {
208
245
expect (
0 commit comments