Skip to content

Commit a30715d

Browse files
dawangkgithub-actions[bot]
authored andcommitted
Auto-formatted the code using Prettier
1 parent 12f4526 commit a30715d

File tree

2 files changed

+119
-118
lines changed

2 files changed

+119
-118
lines changed

course-matrix/backend/__tests__/isValidOffering.test.ts

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,103 @@
1-
import {describe, expect, it, test} from '@jest/globals';
1+
import { describe, expect, it, test } from "@jest/globals";
22

3-
import {createOffering, isValidOffering, Offering, Restriction, RestrictionType,} from '../src/controllers/generatorController';
3+
import {
4+
createOffering,
5+
isValidOffering,
6+
Offering,
7+
Restriction,
8+
RestrictionType,
9+
} from "../src/controllers/generatorController";
410

5-
describe('isValidOffering', () => {
11+
describe("isValidOffering", () => {
612
const sampleOffering: Offering = createOffering({
713
id: 1,
814
course_id: 101,
9-
day: 'MO',
10-
start: '10:00:00',
11-
end: '11:00:00',
15+
day: "MO",
16+
start: "10:00:00",
17+
end: "11:00:00",
1218
});
1319

14-
test('should allow offering if there are no restrictions', () => {
20+
test("should allow offering if there are no restrictions", () => {
1521
expect(isValidOffering(sampleOffering, [])).toBe(true);
1622
});
1723

18-
test('should allow offering if all restrictions are disabled', () => {
24+
test("should allow offering if all restrictions are disabled", () => {
1925
const restrictions: Restriction[] = [
2026
{
2127
type: RestrictionType.RestrictBefore,
22-
days: ['MO'],
23-
startTime: '',
24-
endTime: '09:00:00',
28+
days: ["MO"],
29+
startTime: "",
30+
endTime: "09:00:00",
2531
disabled: true,
2632
numDays: 0,
2733
},
2834
];
2935
expect(isValidOffering(sampleOffering, restrictions)).toBe(true);
3036
});
3137

32-
test(
33-
'should reject offering if it starts before restriction start time',
34-
() => {
35-
const restrictions: Restriction[] = [
36-
{
37-
type: RestrictionType.RestrictBefore,
38-
days: ['MO'],
39-
startTime: '',
40-
endTime: '11:00:00',
41-
disabled: false,
42-
numDays: 0,
43-
},
44-
];
45-
expect(isValidOffering(sampleOffering, restrictions)).toBe(false);
46-
});
38+
test("should reject offering if it starts before restriction start time", () => {
39+
const restrictions: Restriction[] = [
40+
{
41+
type: RestrictionType.RestrictBefore,
42+
days: ["MO"],
43+
startTime: "",
44+
endTime: "11:00:00",
45+
disabled: false,
46+
numDays: 0,
47+
},
48+
];
49+
expect(isValidOffering(sampleOffering, restrictions)).toBe(false);
50+
});
4751

48-
test('should reject offering if it ends after restriction end time', () => {
52+
test("should reject offering if it ends after restriction end time", () => {
4953
const restrictions: Restriction[] = [
5054
{
5155
type: RestrictionType.RestrictAfter,
52-
days: ['MO'],
53-
startTime: '10:30:00',
54-
endTime: '',
56+
days: ["MO"],
57+
startTime: "10:30:00",
58+
endTime: "",
5559
disabled: false,
5660
numDays: 0,
5761
},
5862
];
5963
expect(isValidOffering(sampleOffering, restrictions)).toBe(false);
6064
});
6165

62-
test('should reject offering if it is within restricted time range', () => {
66+
test("should reject offering if it is within restricted time range", () => {
6367
const restrictions: Restriction[] = [
6468
{
6569
type: RestrictionType.RestrictBetween,
66-
days: ['MO'],
67-
startTime: '09:00:00',
68-
endTime: '12:00:00',
70+
days: ["MO"],
71+
startTime: "09:00:00",
72+
endTime: "12:00:00",
6973
disabled: false,
7074
numDays: 0,
7175
},
7276
];
7377
expect(isValidOffering(sampleOffering, restrictions)).toBe(false);
7478
});
7579

76-
test('should reject offering if the day is restricted', () => {
80+
test("should reject offering if the day is restricted", () => {
7781
const restrictions: Restriction[] = [
7882
{
7983
type: RestrictionType.RestrictDay,
80-
days: ['MO'],
81-
startTime: '',
82-
endTime: '',
84+
days: ["MO"],
85+
startTime: "",
86+
endTime: "",
8387
disabled: false,
8488
numDays: 0,
8589
},
8690
];
8791
expect(isValidOffering(sampleOffering, restrictions)).toBe(false);
8892
});
8993

90-
test('should allow offering if the day is not restricted', () => {
94+
test("should allow offering if the day is not restricted", () => {
9195
const restrictions: Restriction[] = [
9296
{
9397
type: RestrictionType.RestrictDay,
94-
days: ['TU'],
95-
startTime: '',
96-
endTime: '',
98+
days: ["TU"],
99+
startTime: "",
100+
endTime: "",
97101
disabled: false,
98102
numDays: 0,
99103
},

0 commit comments

Comments
 (0)