Skip to content

Commit 8ff7678

Browse files
committed
Merge branch 'ty/scrum-180-backend-integration-tests' of https://github.com/UTSC-CSCC01-Software-Engineering-I/term-group-project-c01w25-project-course-matrix into ty/scrum-180-backend-integration-tests
2 parents 118dd4d + 866de6e commit 8ff7678

File tree

1 file changed

+30
-30
lines changed

1 file changed

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

3-
import {supabase} from '../../src/db/setupDb';
4-
import getOfferings from '../../src/services/getOfferings';
3+
import { supabase } from "../../src/db/setupDb";
4+
import getOfferings from "../../src/services/getOfferings";
55

6-
jest.mock('../../src/db/setupDb', () => ({
7-
supabase: {
8-
schema: jest.fn(),
9-
},
10-
}));
6+
jest.mock("../../src/db/setupDb", () => ({
7+
supabase: {
8+
schema: jest.fn(),
9+
},
10+
}));
1111

12-
type SupabaseQueryResult = Promise<{data: any; error: any;}>;
12+
type SupabaseQueryResult = Promise<{ data: any; error: any }>;
1313

14-
describe('getOfferings', () => {
15-
it('returns offering data for a valid course and semester', async () => {
14+
describe("getOfferings", () => {
15+
it("returns offering data for a valid course and semester", async () => {
1616
const mockData = [
1717
{
1818
id: 1,
1919
course_id: 123,
20-
meeting_section: 'L01',
21-
offering: 'Fall 2025',
22-
day: 'Mon',
23-
start: '10:00',
24-
end: '11:00',
25-
location: 'Room 101',
20+
meeting_section: "L01",
21+
offering: "Fall 2025",
22+
day: "Mon",
23+
start: "10:00",
24+
end: "11:00",
25+
location: "Room 101",
2626
current: 30,
2727
max: 40,
2828
is_waitlisted: false,
29-
delivery_mode: 'In-Person',
30-
instructor: 'Dr. Smith',
31-
notes: '',
32-
code: 'ABC123',
29+
delivery_mode: "In-Person",
30+
instructor: "Dr. Smith",
31+
notes: "",
32+
code: "ABC123",
3333
},
3434
];
3535

@@ -38,23 +38,23 @@ describe('getOfferings', () => {
3838
data: mockData,
3939
error: null,
4040
});
41-
const eqMock1 = jest.fn(() => ({eq: eqMock2}));
42-
const selectMock = jest.fn(() => ({eq: eqMock1}));
43-
const fromMock = jest.fn(() => ({select: selectMock}));
44-
const schemaMock = jest.fn(() => ({from: fromMock}));
41+
const eqMock1 = jest.fn(() => ({ eq: eqMock2 }));
42+
const selectMock = jest.fn(() => ({ eq: eqMock1 }));
43+
const fromMock = jest.fn(() => ({ select: selectMock }));
44+
const schemaMock = jest.fn(() => ({ from: fromMock }));
4545

4646
// Replace supabase.schema with our chain
4747
(supabase.schema as jest.Mock).mockImplementation(schemaMock);
4848

4949
// Act
50-
const result = await getOfferings(123, 'Fall 2025');
50+
const result = await getOfferings(123, "Fall 2025");
5151

5252
// Assert
53-
expect(schemaMock).toHaveBeenCalledWith('course');
54-
expect(fromMock).toHaveBeenCalledWith('offerings');
53+
expect(schemaMock).toHaveBeenCalledWith("course");
54+
expect(fromMock).toHaveBeenCalledWith("offerings");
5555
expect(selectMock).toHaveBeenCalled();
56-
expect(eqMock1).toHaveBeenCalledWith('course_id', 123);
57-
expect(eqMock2).toHaveBeenCalledWith('offering', 'Fall 2025');
56+
expect(eqMock1).toHaveBeenCalledWith("course_id", 123);
57+
expect(eqMock2).toHaveBeenCalledWith("offering", "Fall 2025");
5858
expect(result).toEqual(mockData);
5959
});
6060
});

0 commit comments

Comments
 (0)