-
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.
Merge pull request #191 from SELab-2/services
Services
- Loading branch information
Showing
16 changed files
with
1,160 additions
and
120 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
This file was deleted.
Oops, something went wrong.
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,115 @@ | ||
import { describe, it, expect } from 'vitest' | ||
import { Course } from '@/types/Course.ts' | ||
|
||
import { useCourses } from '@/composables/services/courses.service.ts' | ||
|
||
const { | ||
courses, | ||
course, | ||
|
||
getCourseByID, | ||
getCourses, | ||
getCoursesByStudent, | ||
|
||
createCourse, | ||
cloneCourse, | ||
deleteCourse | ||
} = useCourses(); | ||
|
||
// "describe" bundles tests about 1 specific thing; here we're testing course | ||
// aka a test suite | ||
describe("course", (): void => { | ||
// "it" is used to specify tests | ||
// you can also import "test" instead of "it", because it's the exact same | ||
// but with "it", it's easy to read => it (referring to the course) returns correct course year | ||
it("returns correct course year", (): void => { | ||
const course: Course = new Course("1", "course", "description", 2003) | ||
// use expect for assertions | ||
// after expect, there are a multitude of possible functions such as: | ||
// toBe, toEqual, toContain | ||
// check https://vitest.dev/api/expect.html for all possibilities | ||
expect(course.getCourseYear()).toBe("2003 - 2004") | ||
// assert can also be used instead, if you like its syntax more | ||
// check out https://vitest.dev/api/assert.html for more info | ||
}) | ||
|
||
it("gets course data by id", async () => { | ||
await getCourseByID("1") | ||
expect(course.value).not.toBeNull() | ||
expect(course.value?.name).toBe("Math") | ||
expect(course.value?.parent_course).toBeNull() | ||
expect(course.value?.academic_startyear).toBe(2023) | ||
expect(course.value?.description).toBe("Math course") | ||
expect(course.value?.students).toEqual([]) | ||
expect(course.value?.teachers).toEqual([]) | ||
expect(course.value?.assistants).toEqual([]) | ||
expect(course.value?.projects).toEqual([]) | ||
}) | ||
|
||
it("gets courses data", async () => { | ||
await getCourses() | ||
expect(courses.value).not.toBeNull() | ||
expect(courses.value?.[0]?.name).toBe("Math") | ||
expect(courses.value?.[0]?.parent_course).toBeNull() | ||
expect(courses.value?.[0]?.academic_startyear).toBe(2023) | ||
expect(courses.value?.[0]?.description).toBe("Math course") | ||
expect(courses.value?.[0]?.students).toEqual([]) | ||
expect(courses.value?.[0]?.teachers).toEqual([]) | ||
expect(courses.value?.[0]?.assistants).toEqual([]) | ||
expect(courses.value?.[0]?.projects).toEqual([]) | ||
|
||
expect(courses.value?.[1]?.name).toBe("Sel2") | ||
expect(courses.value?.[1]?.parent_course).toBe("3") | ||
expect(courses.value?.[1]?.academic_startyear).toBe(2023) | ||
expect(courses.value?.[1]?.description).toBe("Software course") | ||
expect(courses.value?.[1]?.students).toEqual([]) | ||
expect(courses.value?.[1]?.teachers).toEqual([]) | ||
expect(courses.value?.[1]?.assistants).toEqual([]) | ||
expect(courses.value?.[1]?.projects).toEqual([]) | ||
|
||
expect(courses.value?.[2]?.name).toBe("Sel1") | ||
expect(courses.value?.[2]?.parent_course).toBeNull() | ||
expect(courses.value?.[2]?.academic_startyear).toBe(2022) | ||
expect(courses.value?.[2]?.description).toBe("Software course") | ||
expect(courses.value?.[2]?.students).toEqual([]) | ||
expect(courses.value?.[2]?.teachers).toEqual([]) | ||
expect(courses.value?.[2]?.assistants).toEqual([]) | ||
expect(courses.value?.[2]?.projects).toEqual([]) | ||
|
||
expect(courses.value?.[3]?.name).toBe("Math") | ||
expect(courses.value?.[3]?.parent_course).toBe("1") | ||
expect(courses.value?.[3]?.academic_startyear).toBe(2024) | ||
expect(courses.value?.[3]?.description).toBe("Math course") | ||
expect(courses.value?.[3]?.students).toEqual([]) | ||
expect(courses.value?.[3]?.teachers).toEqual([]) | ||
expect(courses.value?.[3]?.assistants).toEqual([]) | ||
expect(courses.value?.[3]?.projects).toEqual([]) | ||
|
||
expect(courses.value?.[4]?.name).toBe("Math") | ||
expect(courses.value?.[4]?.parent_course).toBe("12") | ||
expect(courses.value?.[4]?.academic_startyear).toBe(2025) | ||
expect(courses.value?.[4]?.description).toBe("Math course") | ||
expect(courses.value?.[4]?.students).toEqual([]) | ||
expect(courses.value?.[4]?.teachers).toEqual([]) | ||
expect(courses.value?.[4]?.assistants).toEqual([]) | ||
expect(courses.value?.[4]?.projects).toEqual([]) | ||
|
||
expect(courses.value?.[5]?.name).toBe("Club brugge") | ||
expect(courses.value?.[5]?.parent_course).toBeNull() | ||
expect(courses.value?.[5]?.academic_startyear).toBe(2023) | ||
expect(courses.value?.[5]?.description).toBeNull() | ||
expect(courses.value?.[5]?.students).toEqual([]) | ||
expect(courses.value?.[5]?.teachers).toEqual([]) | ||
expect(courses.value?.[5]?.assistants).toEqual([]) | ||
expect(courses.value?.[5]?.projects).toEqual([]) | ||
|
||
expect(courses.value?.[6]?.name).toBe("vergeet barbara") | ||
expect(courses.value?.[6]?.parent_course).toBeNull() | ||
expect(courses.value?.[6]?.academic_startyear).toBe(2023) | ||
expect(courses.value?.[6]?.description).toBeNull() | ||
expect(courses.value?.[6]?.students).toEqual([]) | ||
expect(courses.value?.[6]?.teachers).toEqual([]) | ||
expect(courses.value?.[6]?.assistants).toEqual([]) | ||
expect(courses.value?.[6]?.projects).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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {describe, it, expect, beforeEach} from 'vitest' | ||
import { useFaculty } from '@/composables/services/faculties.service.ts' | ||
|
||
const { | ||
faculties, | ||
faculty, | ||
getFacultyByID, | ||
getFacultys, | ||
|
||
createFaculty, | ||
deleteFaculty | ||
} = useFaculty(); | ||
|
||
describe("faculty", (): void => { | ||
it("gets faculty data by id", async () => { | ||
await getFacultyByID("wetenschappen") | ||
expect(faculty.value).not.toBeNull() | ||
expect(faculty.value?.name).toBe("wetenschappen") | ||
}) | ||
|
||
it("gets faculties data", async () => { | ||
await getFacultys() | ||
expect(faculties).not.toBeNull() | ||
expect(Array.isArray(faculties.value)).toBe(true) | ||
expect(faculties.value?.length).toBe(2); | ||
expect(faculties.value?.[0]).not.toBeNull() | ||
expect(faculties.value?.[0].name).toBe("wetenschappen") | ||
expect(faculties.value?.[1]).not.toBeNull() | ||
expect(faculties.value?.[1].name).toBe("voetbal") | ||
}) | ||
}) |
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,56 @@ | ||
import {describe, it, expect, beforeEach} from 'vitest' | ||
import { useGroup } from '@/composables/services/groups.service.ts' | ||
|
||
const { | ||
groups, | ||
group, | ||
getGroupByID, | ||
getGroupsByProject, | ||
getGroupsByStudent, | ||
|
||
createGroup, | ||
deleteGroup | ||
} = useGroup(); | ||
|
||
describe("group", (): void => { | ||
it("gets group data by id", async () => { | ||
await getGroupByID("0") | ||
expect(group.value).not.toBeNull() | ||
expect(group.value?.score).toBe(20) | ||
expect(group.value?.id).toBe("0") | ||
expect(group.value?.project).toBeNull() | ||
expect(group.value?.students).toEqual([]); | ||
expect(group.value?.submissions).toEqual([]); | ||
}) | ||
|
||
it("gets groups data by project", async () => { | ||
await getGroupsByProject("0") | ||
// console.log(groups.value) | ||
// Ensure group data is not null | ||
expect(groups.value).not.toBeNull(); | ||
expect(Array.isArray(groups.value)).toBe(true) | ||
expect(groups.value?.length).toBe(2) | ||
|
||
expect(groups.value?.[0]).not.toBeNull() | ||
expect(groups.value?.[0]?.score).toBe(20) | ||
expect(groups.value?.[0]?.id).toBe("0") | ||
expect(groups.value?.[0]?.project).toBeNull() | ||
expect(groups.value?.[0]?.students).toEqual([]) | ||
expect(groups.value?.[0]?.submissions).toEqual([]) | ||
|
||
expect(groups.value?.[1]).not.toBeNull() | ||
expect(groups.value?.[1]?.score).toBe(18) | ||
expect(groups.value?.[1]?.id).toBe("1") | ||
expect(groups.value?.[1]?.project).toBeNull() | ||
expect(groups.value?.[1]?.students).toEqual([]); | ||
expect(groups.value?.[1]?.submissions).toEqual([]); | ||
}) | ||
|
||
/* | ||
it("create group", async () => { | ||
let gr = new Group("3",10) | ||
await createGroup(gr, "0") | ||
console.log(group.value) | ||
}) | ||
*/ | ||
}) |
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,78 @@ | ||
import {describe, it, expect, beforeEach} from 'vitest' | ||
import { useProject } from '@/composables/services/project.service.ts' | ||
|
||
const { | ||
projects, | ||
project, | ||
getProjectByID, | ||
getProjectsByCourse, | ||
getProjectsByCourseAndDeadline, | ||
getProjectsByStudent, | ||
|
||
createProject, | ||
deleteProject | ||
} = useProject(); | ||
|
||
describe("project", (): void => { | ||
it("gets project data by id", async () => { | ||
await getProjectByID("0") | ||
expect(project.value).not.toBeNull() | ||
expect(project.value?.name).toBe("sel2") | ||
expect(project.value?.course).toBeNull() | ||
expect(project.value?.description).toBe("this is a test") | ||
expect(project.value?.visible).toBe(true) | ||
expect(project.value?.archived).toBe(false) | ||
expect(project.value?.locked_groups).toBe(false) | ||
expect(project.value?.start_date).toStrictEqual(new Date("July 21, 2024 01:15:00")) | ||
expect(project.value?.deadline).toStrictEqual(new Date("July 23, 2024 01:15:00")) | ||
expect(project.value?.max_score).toBe(100) | ||
expect(project.value?.score_visible).toBe(true) | ||
expect(project.value?.group_size).toBe(8) | ||
expect(project.value?.course).toBeNull() | ||
expect(project.value?.structure_checks).toEqual([]) | ||
expect(project.value?.extra_checks).toEqual([]) | ||
expect(project.value?.groups).toEqual([]) | ||
expect(project.value?.submissions).toEqual([]) | ||
}) | ||
|
||
it("gets projects data", async () => { | ||
await getProjectsByCourse("1") | ||
expect(projects).not.toBeNull() | ||
expect(Array.isArray(projects.value)).toBe(true) | ||
expect(projects.value?.length).toBe(2); | ||
expect(projects.value).not.toBeNull() | ||
expect(projects.value?.[0]?.name).toBe("sel2") | ||
expect(projects.value?.[0]?.course).toBeNull() | ||
expect(projects.value?.[0]?.description).toBe("this is a test") | ||
expect(projects.value?.[0]?.visible).toBe(true) | ||
expect(projects.value?.[0]?.archived).toBe(false) | ||
expect(projects.value?.[0]?.locked_groups).toBe(false) | ||
expect(projects.value?.[0]?.start_date).toStrictEqual(new Date("July 21, 2024 01:15:00")) | ||
expect(projects.value?.[0]?.deadline).toStrictEqual(new Date("July 23, 2024 01:15:00")) | ||
expect(projects.value?.[0]?.max_score).toBe(100) | ||
expect(projects.value?.[0]?.score_visible).toBe(true) | ||
expect(projects.value?.[0]?.group_size).toBe(8) | ||
expect(projects.value?.[0]?.course).toBeNull() | ||
expect(projects.value?.[0]?.structure_checks).toEqual([]) | ||
expect(projects.value?.[0]?.extra_checks).toEqual([]) | ||
expect(projects.value?.[0]?.groups).toEqual([]) | ||
expect(projects.value?.[0]?.submissions).toEqual([]) | ||
|
||
expect(projects.value?.[1]?.name).toBe("sel3") | ||
expect(projects.value?.[1]?.course).toBeNull() | ||
expect(projects.value?.[1]?.description).toBe("make a project") | ||
expect(projects.value?.[1]?.visible).toBe(true) | ||
expect(projects.value?.[1]?.archived).toBe(false) | ||
expect(projects.value?.[1]?.locked_groups).toBe(false) | ||
expect(projects.value?.[1]?.start_date).toStrictEqual(new Date("July 21, 2024 01:15:00")) | ||
expect(projects.value?.[1]?.deadline).toStrictEqual(new Date("July 23, 2024 01:15:00")) | ||
expect(projects.value?.[1]?.max_score).toBe(20) | ||
expect(projects.value?.[1]?.score_visible).toBe(false) | ||
expect(projects.value?.[1]?.group_size).toBe(3) | ||
expect(projects.value?.[1]?.course).toBeNull() | ||
expect(projects.value?.[1]?.structure_checks).toEqual([]) | ||
expect(projects.value?.[1]?.extra_checks).toEqual([]) | ||
expect(projects.value?.[1]?.groups).toEqual([]) | ||
expect(projects.value?.[1]?.submissions).toEqual([]) | ||
}) | ||
}) |
Oops, something went wrong.