ahbeng/NUSMods

View on GitHub
scrapers/nus-v2/src/tasks/GetSemesterTimetable.test.ts

Summary

Maintainability
F
5 days
Test Coverage
import CS4238Timetable from './fixtures/api-timetable/CS4238.json';
import MA2213Timetable from './fixtures/api-timetable/MA2213.json';
import CS2100Timetable from './fixtures/api-timetable/CS2100_2.json';
import CN4205ETimetable from './fixtures/api-timetable/CN4205E.json';
import CS1010XTimetable from './fixtures/api-timetable/CS1010X.json';
import RE5001Timetable from './fixtures/api-timetable/RE5001.json';

import GetSemesterTimetable, { transformModgrpToClassNo } from './GetSemesterTimetable';
import { TimetableLesson } from '../types/api';
import { Semester } from '../types/modules';

jest.mock('../services/io/elastic');

describe(transformModgrpToClassNo, () => {
  test('should remove activity string prefix from mod group', () => {
    expect(transformModgrpToClassNo('TE1', 'T')).toEqual('E1');
    expect(transformModgrpToClassNo('TTE1', 'T')).toEqual('TE1');
    expect(transformModgrpToClassNo('LDE1', 'L')).toEqual('DE1');
  });

  test('should passthrough mod groups without activity prefix', () => {
    expect(transformModgrpToClassNo('TDE1', 'L')).toEqual('TDE1');
  });

  test('should trim whitespaces off mod group', () => {
    expect(transformModgrpToClassNo('TDE1 ', 'L')).toEqual('TDE1');
  });

  test('should passthrough mod groups which are just the activity', () => {
    expect(transformModgrpToClassNo('L', 'L')).toEqual('L');
    expect(transformModgrpToClassNo('L ', 'L')).toEqual('L');
  });
});

describe(GetSemesterTimetable, () => {
  function createTask(lessons: TimetableLesson[], semester: Semester = 1) {
    const task = new GetSemesterTimetable(semester, '2018/2019');

    task.api.getSemesterTimetables = jest.fn((term, consumer) => {
      lessons.forEach((lesson) => consumer(lesson));
      return Promise.resolve();
    });

    return task;
  }

  test('should map empty timetable lessons', async () => {
    const task = createTask([]);
    await expect(task.run()).resolves.toEqual({});
  });

  // This module has classes on recess and reading week for some reason
  test('should map CN4205E timetable lessons correctly', async () => {
    const task = createTask(CN4205ETimetable);
    const timetable = await task.run();

    expect(timetable.CN4205E).toMatchInlineSnapshot(`
      [
        {
          "classNo": "1",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "2030",
          "lessonType": "Lecture",
          "size": 30,
          "startTime": "1800",
          "venue": "E5-03-23",
          "weeks": {
            "end": "2018-11-21",
            "start": "2018-08-15",
          },
        },
        {
          "classNo": "1",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "2130",
          "lessonType": "Tutorial",
          "size": 30,
          "startTime": "2030",
          "venue": "E5-03-23",
          "weeks": {
            "end": "2018-11-21",
            "start": "2018-08-15",
          },
        },
      ]
    `);
  });

  // CS4238 is relatively simple - two lesson types, four lessons, every week
  test('should map CS4238 timetable lessons correctly', async () => {
    const task = createTask(CS4238Timetable);
    const timetable = await task.run();

    expect(timetable.CS4238).toMatchInlineSnapshot(`
      [
        {
          "classNo": "1",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "2030",
          "lessonType": "Lecture",
          "size": 40,
          "startTime": "1830",
          "venue": "COM1-B113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "2",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "2030",
          "lessonType": "Lecture",
          "size": 40,
          "startTime": "1830",
          "venue": "COM1-B113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "2",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "2130",
          "lessonType": "Laboratory",
          "size": 40,
          "startTime": "2030",
          "venue": "COM1-B113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "1",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "2130",
          "lessonType": "Laboratory",
          "size": 40,
          "startTime": "2030",
          "venue": "COM1-B113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
      ]
    `);
  });

  // MA2213 is more complicated, with some alternating lessons for lab and tutorials
  test('should map MA2213 timetable lessons correctly', async () => {
    const task = createTask(MA2213Timetable);
    const timetable = await task.run();
    expect(timetable.MA2213).toMatchInlineSnapshot(`
      [
        {
          "classNo": "1",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "1200",
          "lessonType": "Lecture",
          "size": 232,
          "startTime": "1000",
          "venue": "LT33",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "1",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1000",
          "lessonType": "Lecture",
          "size": 232,
          "startTime": "0800",
          "venue": "LT34",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "2",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1800",
          "lessonType": "Laboratory",
          "size": 30,
          "startTime": "1700",
          "venue": "S17-0304",
          "weeks": [
            3,
            5,
            7,
            9,
            11,
          ],
        },
        {
          "classNo": "1",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "1200",
          "lessonType": "Tutorial",
          "size": 30,
          "startTime": "1100",
          "venue": "S17-0404",
          "weeks": [
            4,
            6,
            8,
            10,
            12,
          ],
        },
        {
          "classNo": "4",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "1500",
          "lessonType": "Tutorial",
          "size": 30,
          "startTime": "1400",
          "venue": "S17-0404",
          "weeks": [
            4,
            6,
            8,
            10,
            12,
          ],
        },
        {
          "classNo": "2",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1800",
          "lessonType": "Tutorial",
          "size": 30,
          "startTime": "1700",
          "venue": "S17-0404",
          "weeks": [
            4,
            6,
            8,
            10,
            12,
          ],
        },
        {
          "classNo": "1",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "1200",
          "lessonType": "Laboratory",
          "size": 30,
          "startTime": "1100",
          "venue": "S17-0304",
          "weeks": [
            3,
            5,
            7,
            9,
            11,
          ],
        },
        {
          "classNo": "3",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "1700",
          "lessonType": "Laboratory",
          "size": 30,
          "startTime": "1600",
          "venue": "S17-0304",
          "weeks": [
            3,
            5,
            7,
            9,
            11,
          ],
        },
        {
          "classNo": "3",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "1700",
          "lessonType": "Tutorial",
          "size": 30,
          "startTime": "1600",
          "venue": "S17-0611",
          "weeks": [
            4,
            6,
            8,
            10,
            12,
          ],
        },
        {
          "classNo": "4",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "1500",
          "lessonType": "Laboratory",
          "size": 30,
          "startTime": "1400",
          "venue": "S17-0304",
          "weeks": [
            3,
            5,
            7,
            9,
            11,
          ],
        },
      ]
    `);
  });

  // CS2100 has a lot of lessons, and two joined lecture groups
  test('should map CS2100 timetable lessons correctly', async () => {
    const task = createTask(CS2100Timetable, 2);
    const timetable = await task.run();

    expect(timetable.CS2100).toMatchInlineSnapshot(`
      [
        {
          "classNo": "2",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "1600",
          "lessonType": "Lecture",
          "size": 200,
          "startTime": "1500",
          "venue": "I3-AUD",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "13",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "1100",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1000",
          "venue": "COM1-0207",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "14",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "1200",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1100",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "01",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "1200",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1100",
          "venue": "COM1-0207",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "12",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "1800",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1700",
          "venue": "COM1-0207",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "15",
          "covidZone": "A",
          "day": "Friday",
          "endTime": "0900",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "0800",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "17",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "1400",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1300",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "18",
          "covidZone": "A",
          "day": "Friday",
          "endTime": "1400",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1300",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "19",
          "covidZone": "A",
          "day": "Friday",
          "endTime": "1500",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1400",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "20",
          "covidZone": "A",
          "day": "Friday",
          "endTime": "1600",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1500",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "05",
          "covidZone": "A",
          "day": "Friday",
          "endTime": "1200",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1100",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "02",
          "covidZone": "A",
          "day": "Friday",
          "endTime": "1000",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "0900",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "16",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "1300",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1200",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "2",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1200",
          "lessonType": "Lecture",
          "size": 200,
          "startTime": "1000",
          "venue": "I3-AUD",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "1",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "1500",
          "lessonType": "Lecture",
          "size": 200,
          "startTime": "1400",
          "venue": "I3-AUD",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "1",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "1800",
          "lessonType": "Lecture",
          "size": 200,
          "startTime": "1600",
          "venue": "I3-AUD",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "11",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1600",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1500",
          "venue": "COM1-0203",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "10",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "1000",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "0900",
          "venue": "COM1-0201",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "13",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "1100",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1000",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "19",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "1700",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1600",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "06",
          "covidZone": "A",
          "day": "Friday",
          "endTime": "1300",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1200",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "04",
          "covidZone": "A",
          "day": "Wednesday",
          "endTime": "1200",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1100",
          "venue": "COM1-0201",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "09",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1700",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1600",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "20",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "1800",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1700",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "03",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "1100",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1000",
          "venue": "COM1-0207",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "05",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1300",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1200",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "06",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1400",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1300",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "07",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1500",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1400",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "08",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1600",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1500",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "08",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1300",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1200",
          "venue": "COM1-0207",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "02",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1000",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "0900",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "03",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1100",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1000",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "04",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1200",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1100",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "16",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "1400",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1300",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "17",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "1500",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1400",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "18",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "1600",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1500",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "10",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1800",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1700",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "11",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "0900",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "0800",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "12",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "1000",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "0900",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "14",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "1200",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1100",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "15",
          "covidZone": "A",
          "day": "Thursday",
          "endTime": "1300",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "1200",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "07",
          "covidZone": "A",
          "day": "Tuesday",
          "endTime": "1400",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1300",
          "venue": "COM1-0209",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "09",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "1700",
          "lessonType": "Tutorial",
          "size": 20,
          "startTime": "1600",
          "venue": "COM1-0203",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
        {
          "classNo": "01",
          "covidZone": "A",
          "day": "Monday",
          "endTime": "0900",
          "lessonType": "Laboratory",
          "size": 20,
          "startTime": "0800",
          "venue": "COM1-0113",
          "weeks": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
          ],
        },
      ]
    `);
  });

  // CS1010X has lessons extending outside the normal semester week range
  test('should map CS1010X timetable lessons correctly', async () => {
    const task = createTask(CS1010XTimetable as TimetableLesson[]);
    const output = await task.run();

    expect(output).toMatchInlineSnapshot(`
      {
        "CS1010X": [
          {
            "classNo": "1",
            "covidZone": "A",
            "day": "Thursday",
            "endTime": "1000",
            "lessonType": "Recitation",
            "size": 48,
            "startTime": "0900",
            "venue": "SR_LT19",
            "weeks": {
              "end": "2019-06-20",
              "start": "2019-01-17",
            },
          },
          {
            "classNo": "2",
            "covidZone": "A",
            "day": "Thursday",
            "endTime": "1300",
            "lessonType": "Recitation",
            "size": 48,
            "startTime": "1200",
            "venue": "SR_LT19",
            "weeks": {
              "end": "2019-06-20",
              "start": "2019-01-17",
            },
          },
          {
            "classNo": "01",
            "covidZone": "A",
            "day": "Thursday",
            "endTime": "1100",
            "lessonType": "Tutorial",
            "size": 20,
            "startTime": "1000",
            "venue": "SR_LT19",
            "weeks": {
              "end": "2019-06-20",
              "start": "2019-01-17",
            },
          },
          {
            "classNo": "02",
            "covidZone": "A",
            "day": "Thursday",
            "endTime": "1200",
            "lessonType": "Tutorial",
            "size": 20,
            "startTime": "1100",
            "venue": "SR_LT19",
            "weeks": {
              "end": "2019-06-20",
              "start": "2019-01-17",
            },
          },
          {
            "classNo": "03",
            "covidZone": "A",
            "day": "Thursday",
            "endTime": "1400",
            "lessonType": "Tutorial",
            "size": 20,
            "startTime": "1300",
            "venue": "SR_LT19",
            "weeks": {
              "end": "2019-06-20",
              "start": "2019-01-17",
            },
          },
          {
            "classNo": "04",
            "covidZone": "A",
            "day": "Thursday",
            "endTime": "1500",
            "lessonType": "Tutorial",
            "size": 20,
            "startTime": "1400",
            "venue": "SR_LT19",
            "weeks": {
              "end": "2019-06-20",
              "start": "2019-01-17",
            },
          },
        ],
      }
    `);
  });

  // RE5001 has lessons with only one session outside of the normal semester weeks
  // Tests for accidentally introducing infinity when calculating weekInterval
  test('should map RE5001 timetable lessons correctly', async () => {
    const task = createTask(RE5001Timetable);
    const output = await task.run();

    expect(output).toMatchInlineSnapshot(`
      {
        "RE5001": [
          {
            "classNo": "1",
            "covidZone": "Unknown",
            "day": "Tuesday",
            "endTime": "1800",
            "lessonType": "Lecture",
            "size": 60,
            "startTime": "0900",
            "venue": "SDE-423",
            "weeks": {
              "end": "2018-08-07",
              "start": "2018-08-07",
            },
          },
          {
            "classNo": "1",
            "covidZone": "Unknown",
            "day": "Wednesday",
            "endTime": "1800",
            "lessonType": "Lecture",
            "size": 60,
            "startTime": "0900",
            "venue": "SDE-423",
            "weeks": {
              "end": "2018-08-08",
              "start": "2018-08-08",
            },
          },
          {
            "classNo": "1",
            "covidZone": "Unknown",
            "day": "Monday",
            "endTime": "1800",
            "lessonType": "Lecture",
            "size": 60,
            "startTime": "0900",
            "venue": "SDE-423",
            "weeks": {
              "end": "2018-08-06",
              "start": "2018-08-06",
            },
          },
          {
            "classNo": "1",
            "covidZone": "Unknown",
            "day": "Friday",
            "endTime": "1800",
            "lessonType": "Lecture",
            "size": 60,
            "startTime": "0900",
            "venue": "SDE-423",
            "weeks": {
              "end": "2018-08-10",
              "start": "2018-08-10",
            },
          },
          {
            "classNo": "1",
            "covidZone": "Unknown",
            "day": "Saturday",
            "endTime": "1300",
            "lessonType": "Lecture",
            "size": 60,
            "startTime": "0900",
            "venue": "SDE-423",
            "weeks": {
              "end": "2018-08-11",
              "start": "2018-08-11",
            },
          },
        ],
      }
    `);
  });
});