1
1
import { CS1010S , CS3216 , MA1521 } from '__mocks__/modules' ;
2
- import { LessonOption } from 'types/optimiser' ;
2
+ import { LessonOption , TimeRange } from 'types/optimiser' ;
3
3
import { Module , WorkingDays } from 'types/modules' ;
4
4
import { shuffle } from 'lodash' ;
5
5
import { OptimiseResponse } from 'apis/optimiser' ;
@@ -23,6 +23,9 @@ import {
23
23
isSaturdayInOptions ,
24
24
sortDays ,
25
25
getUnassignedLessonOptions ,
26
+ getOptimiserAcadYear ,
27
+ getTimeValues ,
28
+ getOptimiserTime ,
26
29
} from './optimiser' ;
27
30
import { getModuleTimetable } from './modules' ;
28
31
@@ -35,11 +38,25 @@ describe('getLessonKey', () => {
35
38
} ) ;
36
39
37
40
describe ( 'getDisplayText' , ( ) => {
38
- it ( 'should format display text' , ( ) => {
41
+ it ( 'getDisplayText should format display text' , ( ) => {
39
42
expect ( getDisplayText ( 'CS1010S' , 'Lecture' ) ) . toEqual ( 'CS1010S Lecture' ) ;
40
43
} ) ;
41
44
} ) ;
42
45
46
+ describe ( 'getOptimiserAcadYear' , ( ) => {
47
+ it ( 'getOptimiserAcadYear should format academic year' , ( ) => {
48
+ expect ( getOptimiserAcadYear ( '2024/2025' ) ) . toEqual ( '2024-2025' ) ;
49
+ } ) ;
50
+ } ) ;
51
+
52
+ describe ( 'getOptimiserTime' , ( ) => {
53
+ it ( 'getOptimiserTime should format time' , ( ) => {
54
+ expect ( getOptimiserTime ( '0800' ) ) . toEqual ( '08:00' ) ;
55
+ expect ( getOptimiserTime ( '1000' ) ) . toEqual ( '10:00' ) ;
56
+ expect ( getOptimiserTime ( '1030' ) ) . toEqual ( '10:30' ) ;
57
+ } ) ;
58
+ } ) ;
59
+
43
60
describe ( 'getLessonTypes' , ( ) => {
44
61
it ( 'should map lessons to unique lesson types' , ( ) => {
45
62
const lessons = getModuleTimetable ( defaultModule , 1 ) ;
@@ -243,3 +260,14 @@ describe('isSaturdayInOptions', () => {
243
260
expect ( isSaturdayInOptions ( lessonOptions ) ) . toBe ( true ) ;
244
261
} ) ;
245
262
} ) ;
263
+
264
+ describe ( 'getTimeValues' , ( ) => {
265
+ it ( 'should return a range of times' , ( ) => {
266
+ const timeRange : TimeRange = {
267
+ earliest : '0800' ,
268
+ latest : '1030' ,
269
+ } ;
270
+ const expected = [ '0800' , '0830' , '0900' , '0930' , '1000' , '1030' ] ;
271
+ expect ( getTimeValues ( timeRange ) ) . toEqual ( expected ) ;
272
+ } ) ;
273
+ } ) ;
0 commit comments