@@ -251,7 +251,7 @@ describe(TodayContainerComponent, () => {
251
251
} ) ;
252
252
253
253
describe ( mapStateToProps , ( ) => {
254
- test ( 'should use correct semester' , ( ) => {
254
+ test ( 'should use correct semester (test 1, special case) ' , ( ) => {
255
255
// On week -1 of sem 2 the semester should be 2, not 1
256
256
const ownProps : any = {
257
257
// Week -1 of sem 2 of AY2018/2019
@@ -280,3 +280,123 @@ describe(mapStateToProps, () => {
280
280
expect ( mapStateToProps ( state , ownProps ) . timetableWithLessons ) . toHaveProperty ( 'CS1010S' ) ;
281
281
} ) ;
282
282
} ) ;
283
+
284
+ describe ( mapStateToProps , ( ) => {
285
+ test ( 'should use correct semester (test 2)' , ( ) => {
286
+ // On week -1 of orientation week, it should be special term II
287
+ const ownProps : any = {
288
+ currentTime : new Date ( '2024-08-04T00:00:00.000Z' ) ,
289
+ } ;
290
+
291
+ const state : any = {
292
+ moduleBank : { modules : { } } ,
293
+ timetables : {
294
+ lessons : {
295
+ [ 4 ] : {
296
+ CS3216 : { } ,
297
+ } ,
298
+ [ 1 ] : {
299
+ CS1010S : { } ,
300
+ } ,
301
+ } ,
302
+ colors : {
303
+ [ 4 ] : COLORS ,
304
+ [ 1 ] : COLORS ,
305
+ } ,
306
+ } ,
307
+ } ;
308
+
309
+ // Should return special term II timetable, not sem 1
310
+ expect ( mapStateToProps ( state , ownProps ) . timetableWithLessons ) . toHaveProperty ( 'CS3216' ) ;
311
+ } ) ;
312
+ } ) ;
313
+
314
+ describe ( mapStateToProps , ( ) => {
315
+ test ( 'should use correct semester (test 3)' , ( ) => {
316
+ // On orientation week, it should be sem1
317
+ const ownProps : any = {
318
+ currentTime : new Date ( '2024-08-05T00:00:00.000Z' ) ,
319
+ } ;
320
+
321
+ const state : any = {
322
+ moduleBank : { modules : { } } ,
323
+ timetables : {
324
+ lessons : {
325
+ [ 4 ] : {
326
+ CS3216 : { } ,
327
+ } ,
328
+ [ 1 ] : {
329
+ CS1010S : { } ,
330
+ } ,
331
+ } ,
332
+ colors : {
333
+ [ 4 ] : COLORS ,
334
+ [ 1 ] : COLORS ,
335
+ } ,
336
+ } ,
337
+ } ;
338
+
339
+ // Should return sem1 timetable
340
+ expect ( mapStateToProps ( state , ownProps ) . timetableWithLessons ) . toHaveProperty ( 'CS1010S' ) ;
341
+ } ) ;
342
+ } ) ;
343
+
344
+ describe ( mapStateToProps , ( ) => {
345
+ test ( 'should use correct semester (test 4)' , ( ) => {
346
+ // On week -1 of special term I, it should be sem2
347
+ const ownProps : any = {
348
+ currentTime : new Date ( '2025-05-11T00:00:00.000Z' ) ,
349
+ } ;
350
+
351
+ const state : any = {
352
+ moduleBank : { modules : { } } ,
353
+ timetables : {
354
+ lessons : {
355
+ [ 2 ] : {
356
+ CS3216 : { } ,
357
+ } ,
358
+ [ 3 ] : {
359
+ CS1010S : { } ,
360
+ } ,
361
+ } ,
362
+ colors : {
363
+ [ 2 ] : COLORS ,
364
+ [ 3 ] : COLORS ,
365
+ } ,
366
+ } ,
367
+ } ;
368
+
369
+ // Should return sem2 timetable
370
+ expect ( mapStateToProps ( state , ownProps ) . timetableWithLessons ) . toHaveProperty ( 'CS3216' ) ;
371
+ } ) ;
372
+ } ) ;
373
+
374
+ describe ( mapStateToProps , ( ) => {
375
+ test ( 'should use correct semester (test 5)' , ( ) => {
376
+ // On week -1 of special term II, it should be special term I
377
+ const ownProps : any = {
378
+ currentTime : new Date ( '2025-06-22T00:00:00.000Z' ) ,
379
+ } ;
380
+
381
+ const state : any = {
382
+ moduleBank : { modules : { } } ,
383
+ timetables : {
384
+ lessons : {
385
+ [ 3 ] : {
386
+ CS3216 : { } ,
387
+ } ,
388
+ [ 4 ] : {
389
+ CS1010S : { } ,
390
+ } ,
391
+ } ,
392
+ colors : {
393
+ [ 3 ] : COLORS ,
394
+ [ 4 ] : COLORS ,
395
+ } ,
396
+ } ,
397
+ } ;
398
+
399
+ // Should return special term I timetable
400
+ expect ( mapStateToProps ( state , ownProps ) . timetableWithLessons ) . toHaveProperty ( 'CS3216' ) ;
401
+ } ) ;
402
+ } ) ;
0 commit comments