-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65a7bfa
commit 65b9a98
Showing
3 changed files
with
108 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import {describe, it, expect, beforeEach} from 'vitest' | ||
import { useAssistant } from '@/composables/services/assistant.service.ts' | ||
|
||
const { | ||
assistants, | ||
assistant, | ||
response, | ||
|
||
getAssistantByID, | ||
getAssistantByCourse, | ||
getAssistants, | ||
|
||
createAssistant, | ||
deleteAssistant, | ||
|
||
assistantJoinCourse, | ||
assistantLeaveCourse | ||
} = useAssistant(); | ||
|
||
describe("assistant", (): void => { | ||
it("gets assistant data by id", async () => { | ||
await getAssistantByID("235") | ||
expect(assistant.value).not.toBeNull() | ||
expect(assistant.value?.username).toBe("bsimpson") | ||
expect(assistant.value?.is_staff).toBe(false) | ||
expect(assistant.value?.email).toBe("[email protected]") | ||
expect(assistant.value?.first_name).toBe("Bart") | ||
expect(assistant.value?.last_name).toBe("Simpson") | ||
expect(assistant.value?.last_enrolled).toBe(2023) | ||
// expect(assistant.value?.last_login).toBeNull() | ||
// expect(assistant.value?.create_time).toEqual(new Date("July 21, 2024 01:15:00")) | ||
expect(assistant.value?.courses).toEqual([]) | ||
expect(assistant.value?.faculties).toEqual([]) | ||
}) | ||
|
||
it("gets teacher data", async () => { | ||
await getAssistants() | ||
expect(assistants).not.toBeNull() | ||
expect(Array.isArray(assistants.value)).toBe(true) | ||
expect(assistants.value?.length).toBe(2); | ||
|
||
expect(assistants.value?.[0]?.username).toBe("bsimpson") | ||
expect(assistants.value?.[0]?.is_staff).toBe(false) | ||
expect(assistants.value?.[0]?.email).toBe("[email protected]") | ||
expect(assistants.value?.[0]?.first_name).toBe("Bart") | ||
expect(assistants.value?.[0]?.last_name).toBe("Simpson") | ||
expect(assistants.value?.[0]?.last_enrolled).toBe(2023) | ||
// expect(assistants.value?.[0]?.last_login).toBeNull() | ||
// expect(assistants.value?.[0]?.create_time).toEqual(new Date("July 21, 2024 01:15:00")) | ||
expect(assistants.value?.[0]?.courses).toEqual([]) | ||
expect(assistants.value?.[0]?.faculties).toEqual([]) | ||
|
||
expect(assistants.value?.[1]?.username).toBe("kclijster") | ||
expect(assistants.value?.[1]?.is_staff).toBe(false) | ||
expect(assistants.value?.[1]?.email).toBe("[email protected]") | ||
expect(assistants.value?.[1]?.first_name).toBe("Kim") | ||
expect(assistants.value?.[1]?.last_name).toBe("Clijsters") | ||
expect(assistants.value?.[1]?.last_enrolled).toBe(2023) | ||
// expect(assistants.value?.[0]?.last_login).toBeNull() | ||
// expect(assistants.value?.[0]?.create_time).toEqual(new Date("July 21, 2024 01:15:00")) | ||
expect(assistants.value?.[1]?.courses).toEqual([]) | ||
expect(assistants.value?.[1]?.faculties).toEqual([]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,23 +196,50 @@ const teachers = [ | |
first_name: "Tom", | ||
last_name: "Boonen", | ||
last_enrolled: 2023, | ||
create_time: new Date("July 21, 2024 01:15:00") | ||
create_time: new Date("July 21, 2024 01:15:00") | ||
}, | ||
{ | ||
id: "124", | ||
courses: [], | ||
faculties: [], | ||
last_login: null, | ||
username: "psagan", | ||
is_staff: false, | ||
email: "[email protected]", | ||
first_name: "Peter", | ||
last_name: "Sagan", | ||
last_enrolled: 2023, | ||
create_time: new Date("July 21, 2024 01:15:00") | ||
create_time: new Date("July 21, 2024 01:15:00") | ||
} | ||
] | ||
|
||
const assistants = [ | ||
{ | ||
id: "235", | ||
courses: [], | ||
faculties: [], | ||
last_login: null, | ||
username: "bsimpson", | ||
is_staff: false, | ||
email: "[email protected]", | ||
first_name: "Bart", | ||
last_name: "Simpson", | ||
last_enrolled: 2023, | ||
create_time: new Date("July 21, 2024 01:15:00") | ||
}, | ||
{ | ||
id: "236", | ||
courses: [], | ||
faculties: [], | ||
last_login: null, | ||
username: "kclijster", | ||
is_staff: false, | ||
email: "[email protected]", | ||
first_name: "Kim", | ||
last_name: "Clijsters", | ||
last_enrolled: 2023, | ||
create_time: new Date("July 21, 2024 01:15:00") | ||
} | ||
] | ||
|
||
export const restHandlers = [ | ||
http.get(baseUrl + endpoints.groups.retrieve.replace('{id}', ':id'), | ||
({ params }) => { | ||
|
@@ -224,6 +251,11 @@ export const restHandlers = [ | |
return HttpResponse.json(teachers.find(x => x.id == params.id)) | ||
} | ||
), | ||
http.get(baseUrl + endpoints.assistants.retrieve.replace('{id}', ':id'), | ||
({ params }) => { | ||
return HttpResponse.json(assistants.find(x => x.id == params.id)) | ||
} | ||
), | ||
http.get(baseUrl + endpoints.students.retrieve.replace('{id}', ':id'), | ||
({ params }) => { | ||
return HttpResponse.json(students.find(x => x.id == params.id)) | ||
|
@@ -273,6 +305,11 @@ export const restHandlers = [ | |
({}) => { | ||
return HttpResponse.json(teachers) | ||
} | ||
), | ||
http.get(baseUrl + endpoints.assistants.index, | ||
({}) => { | ||
return HttpResponse.json(assistants) | ||
} | ||
) | ||
|
||
/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters