Skip to content

Commit

Permalink
Merge pull request #21 from hotungkhanh/kan-65/frontend-tests
Browse files Browse the repository at this point in the history
feat: add test for sending multiple solve requests to server
  • Loading branch information
JackTong24 authored Sep 25, 2024
2 parents 83fba30 + 55d0da8 commit 032b94c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions frontend/src/tests/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import moment from 'moment';
* Check that output matches expected output.
*/
describe('fetchTimetableSolution', () => {
/**
* Validate end-to-end scheduling and data consistency of 1 API method call.
*/
it('return TimetableSolution', async () => {
const problem: TimetableProblem = {
units: [{ unitID: 0, name: "Unit0", duration: 1200, students: [], wantsLab: true }],
Expand All @@ -27,6 +30,25 @@ describe('fetchTimetableSolution', () => {
expect(solution?.rooms).toEqual(problem.rooms);

});

/**
* Validate that backend server can handle multiple solve requests concurrently.
*/
it ('can be called multiple times', async () => {
const problem: TimetableProblem = {
units: [{ unitID: 0, name: "Unit0", duration: 1200, students: [], wantsLab: true }],
daysOfWeek: ["MONDAY"],
startTimes: ["11:00:00"],
rooms: [{ id: "Room A", capacity: 10, lab: true }]
};

const solutions = await Promise.all([fetchTimetableSolution(problem), fetchTimetableSolution(problem), fetchTimetableSolution(problem)]);

for (let i = 0; i < solutions.length; i++) {
expect(solutions[i]).not.toBeNull();
}

});

});

Expand Down

0 comments on commit 032b94c

Please sign in to comment.