Skip to content

Commit 01c454a

Browse files
kevin-lanngithub-actions[bot]
authored andcommitted
Auto-formatted the code using Prettier
1 parent 8cbc9b2 commit 01c454a

File tree

4 files changed

+55
-62
lines changed

4 files changed

+55
-62
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe("analyzeQuery", () => {
9191

9292
test("should detect multiple namespaces in a single query", () => {
9393
const result = analyzeQuery(
94-
"What are the prerequisites and schedule for CSC108?"
94+
"What are the prerequisites and schedule for CSC108?",
9595
);
9696
expect(result.requiresSearch).toBe(true);
9797
expect(result.relevantNamespaces).toContain("prerequisites");
Lines changed: 52 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,124 @@
11
import {
22
BREADTH_REQUIREMENT_KEYWORDS,
3-
YEAR_LEVEL_KEYWORDS
4-
} from '../src/constants/promptKeywords';
5-
import { includeFilters } from '../src/utils/includeFilters';
3+
YEAR_LEVEL_KEYWORDS,
4+
} from "../src/constants/promptKeywords";
5+
import { includeFilters } from "../src/utils/includeFilters";
66
import { describe, test, expect, jest, beforeEach } from "@jest/globals";
7-
import * as ModuleType from '../src/utils/convert-breadth-requirement';
8-
import * as ModuleType0 from '../src/utils/convert-year-level';
7+
import * as ModuleType from "../src/utils/convert-breadth-requirement";
8+
import * as ModuleType0 from "../src/utils/convert-year-level";
99

1010
// Create mock functions
11-
const mockConvertBreadthRequirement = jest.fn((namespace) => `converted_${namespace}`);
11+
const mockConvertBreadthRequirement = jest.fn(
12+
(namespace) => `converted_${namespace}`,
13+
);
1214
const mockConvertYearLevel = jest.fn((namespace) => `converted_${namespace}`);
1315

1416
// Mock the modules
15-
jest.mock('../src/utils/convert-breadth-requirement', () => ({
16-
convertBreadthRequirement: (namespace: string) => mockConvertBreadthRequirement(namespace)
17+
jest.mock("../src/utils/convert-breadth-requirement", () => ({
18+
convertBreadthRequirement: (namespace: string) =>
19+
mockConvertBreadthRequirement(namespace),
1720
}));
1821

19-
jest.mock('../src/utils/convert-year-level', () => ({
20-
convertYearLevel: (namespace: string) => mockConvertYearLevel(namespace)
22+
jest.mock("../src/utils/convert-year-level", () => ({
23+
convertYearLevel: (namespace: string) => mockConvertYearLevel(namespace),
2124
}));
2225

23-
describe('includeFilters', () => {
26+
describe("includeFilters", () => {
2427
beforeEach(() => {
2528
// Clear mock data before each test
2629
mockConvertBreadthRequirement.mockClear();
2730
mockConvertYearLevel.mockClear();
2831
});
2932

30-
test('should return empty object when no filters match', () => {
31-
const query = 'something random';
33+
test("should return empty object when no filters match", () => {
34+
const query = "something random";
3235
const result = includeFilters(query);
3336
expect(result).toEqual({});
3437
});
3538

36-
test('should match breadth requirement keywords case-insensitively', () => {
37-
const query = 'I want to study ART Literature';
39+
test("should match breadth requirement keywords case-insensitively", () => {
40+
const query = "I want to study ART Literature";
3841
const result = includeFilters(query);
3942
expect(result).toEqual({
40-
$or: [
41-
{ breadth_requirement: { $eq: 'converted_ART_LIT_LANG' } }
42-
]
43+
$or: [{ breadth_requirement: { $eq: "converted_ART_LIT_LANG" } }],
4344
});
4445
});
4546

46-
test('should match year level keywords case-insensitively', () => {
47-
const query = 'Looking for A-level courses';
47+
test("should match year level keywords case-insensitively", () => {
48+
const query = "Looking for A-level courses";
4849
const result = includeFilters(query);
4950
expect(result).toEqual({
50-
$or: [
51-
{ year_level: { $eq: 'converted_first_year' } }
52-
]
51+
$or: [{ year_level: { $eq: "converted_first_year" } }],
5352
});
5453
});
5554

56-
test('should combine both breadth and year level filters with $and when both are present', () => {
57-
const query = 'Natural Science First-Year courses';
55+
test("should combine both breadth and year level filters with $and when both are present", () => {
56+
const query = "Natural Science First-Year courses";
5857
const result = includeFilters(query);
5958
expect(result).toEqual({
6059
$and: [
6160
{
62-
$or: [
63-
{ breadth_requirement: { $eq: 'converted_NAT_SCI' } }
64-
]
61+
$or: [{ breadth_requirement: { $eq: "converted_NAT_SCI" } }],
6562
},
6663
{
67-
$or: [
68-
{ year_level: { $eq: 'converted_first_year' } }
69-
]
70-
}
71-
]
64+
$or: [{ year_level: { $eq: "converted_first_year" } }],
65+
},
66+
],
7267
});
7368
});
7469

75-
test('should handle multiple breadth requirements', () => {
76-
const query = 'social science or quantitative reasoning';
70+
test("should handle multiple breadth requirements", () => {
71+
const query = "social science or quantitative reasoning";
7772
const result = includeFilters(query);
7873
expect(result).toEqual({
7974
$or: [
80-
{ breadth_requirement: { $eq: 'converted_SOCIAL_SCI' } },
81-
{ breadth_requirement: { $eq: 'converted_QUANT' } }
82-
]
75+
{ breadth_requirement: { $eq: "converted_SOCIAL_SCI" } },
76+
{ breadth_requirement: { $eq: "converted_QUANT" } },
77+
],
8378
});
8479
});
8580

86-
test('should handle multiple year levels', () => {
87-
const query = 'third year or fourth-year courses';
81+
test("should handle multiple year levels", () => {
82+
const query = "third year or fourth-year courses";
8883
const result = includeFilters(query);
8984
expect(result).toEqual({
9085
$or: [
91-
{ year_level: { $eq: 'converted_third_year' } },
92-
{ year_level: { $eq: 'converted_fourth_year' } }
93-
]
86+
{ year_level: { $eq: "converted_third_year" } },
87+
{ year_level: { $eq: "converted_fourth_year" } },
88+
],
9489
});
9590
});
9691

97-
test('should handle multiple breadth requirements and year levels', () => {
98-
const query = 'history philosophy B-level or C-level';
92+
test("should handle multiple breadth requirements and year levels", () => {
93+
const query = "history philosophy B-level or C-level";
9994
const result = includeFilters(query);
100-
console.log(result)
95+
console.log(result);
10196
expect(result).toEqual({
10297
$and: [
10398
{
104-
$or: [
105-
{ breadth_requirement: { $eq: 'converted_HIS_PHIL_CUL' } }
106-
]
99+
$or: [{ breadth_requirement: { $eq: "converted_HIS_PHIL_CUL" } }],
107100
},
108101
{
109102
$or: [
110-
{ year_level: { $eq: 'converted_second_year' } },
111-
{ year_level: { $eq: 'converted_third_year' } }
112-
]
113-
}
114-
]
103+
{ year_level: { $eq: "converted_second_year" } },
104+
{ year_level: { $eq: "converted_third_year" } },
105+
],
106+
},
107+
],
115108
});
116109
});
117110

118-
test('should ignore partial keyword matches', () => {
111+
test("should ignore partial keyword matches", () => {
119112
// "art" alone shouldn't match "art literature language"
120-
const query = 'art courses';
113+
const query = "art courses";
121114
const result = includeFilters(query);
122115
// This should not match any specific filter since "art" alone isn't in the keywords
123116
expect(result).toEqual({});
124117
});
125118

126-
test('should handle edge case with empty query', () => {
127-
const query = '';
119+
test("should handle edge case with empty query", () => {
120+
const query = "";
128121
const result = includeFilters(query);
129122
expect(result).toEqual({});
130123
});
131-
});
124+
});

course-matrix/backend/src/utils/analyzeQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function analyzeQuery(query: string): {
5757
"prerequisites",
5858
"corequisites",
5959
"departments",
60-
"programs"
60+
"programs",
6161
);
6262
}
6363

course-matrix/backend/src/utils/includeFilters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function includeFilters(query: string) {
1616
if (keywords.some((keyword) => lowerQuery.includes(keyword))) {
1717
relaventBreadthRequirements.push(convertBreadthRequirement(namespace));
1818
}
19-
}
19+
},
2020
);
2121

2222
Object.entries(YEAR_LEVEL_KEYWORDS).forEach(([namespace, keywords]) => {

0 commit comments

Comments
 (0)