Skip to content

Commit

Permalink
chore: fix asserttypes
Browse files Browse the repository at this point in the history
  • Loading branch information
francisvaut committed May 21, 2024
1 parent b129289 commit d457f69
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 43 deletions.
24 changes: 6 additions & 18 deletions frontend/src/test/unit/services/group_service.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-non-null-assertion */

/* eslint-disable @typescript-eslint/no-unused-vars */
import { describe, it, expect, assertType } from 'vitest';
import { useGroup } from '@/composables/services/group.service.ts';
import { Group } from '@/types/Group';
import { useProject } from '@/composables/services/project.service';
import { type Project } from '@/types/Project';

const {
groups,
group,
getGroupByID,
getGroupsByProject,
getGroupsByStudent,

createGroup,
deleteGroup,
} = useGroup();
const { groups, group, getGroupByID, getGroupsByProject, getGroupsByStudent } = useGroup();

function resetService(): void {
group.value = null;
Expand All @@ -31,7 +19,7 @@ describe('group', (): void => {
expect(group.value).not.toBeNull();
expect(group.value?.id).toBe('0');
expect(group.value?.score).toBe(20);
assertType(group.value?.project!);
assertType<Project>(group.value?.project!);
expect(group.value?.students).toBeNull();
expect(group.value?.submissions).toBeNull();
});
Expand All @@ -46,13 +34,13 @@ describe('group', (): void => {

expect(groups.value?.[0].id).toBe('0');
expect(groups.value?.[0].score).toBe(20);
assertType(groups.value?.[0].project!);
assertType<Project>(groups.value?.[0].project!);
expect(groups.value?.[0].students).toBeNull;
expect(groups.value?.[0].submissions).toBeNull();

expect(groups.value?.[1].id).toBe('1');
expect(groups.value?.[1].score).toBe(18);
assertType(groups.value?.[1].project!);
assertType<Project>(groups.value?.[1].project!);
expect(groups.value?.[1].students).toBeNull;
expect(groups.value?.[1].submissions).toBeNull();
});
Expand All @@ -67,7 +55,7 @@ describe('group', (): void => {

expect(groups.value?.[0].id).toBe('0');
expect(groups.value?.[0].score).toBe(20);
assertType(groups.value?.[0].project!);
assertType<Project>(groups.value?.[0].project!);
expect(groups.value?.[0].students).toBeNull;
expect(groups.value?.[0].submissions).toBeNull();
});
Expand Down
47 changes: 22 additions & 25 deletions frontend/src/test/unit/services/project_service.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-non-null-assertion */

import { describe, it, expect, assertType } from 'vitest';
import { useProject } from '@/composables/services/project.service.ts';
import { useCourses } from '@/composables/services/course.service';
Expand Down Expand Up @@ -42,13 +44,12 @@ describe('project', (): void => {
expect(project.value?.max_score).toBe(100);
expect(project.value?.score_visible).toBe(true);
expect(project.value?.group_size).toBe(5);
assertType(project.value?.course!);
assertType(project.value?.status!);
assertType(project.value?.structure_file!);
assertType<Course>(project.value?.course!);
assertType<SubmissionStatus>(project.value?.status!);
assertType<File>(project.value?.structure_file!);
expect(project.value?.structureChecks).toBe(null);
expect(project.value?.extra_checks).toBe(null);
assertType(Array.isArray(project.value?.groups));
assertType((project.value?.groups?.[0] ?? null)!);
assertType<Group[]>(project.value?.groups!);
expect(project.value?.submissions).toBe(null);
});

Expand All @@ -70,13 +71,12 @@ describe('project', (): void => {
expect(projects.value?.[0]?.max_score).toBe(100);
expect(projects.value?.[0]?.score_visible).toBe(true);
expect(projects.value?.[0]?.group_size).toBe(5);
assertType(projects.value?.[0]?.course!);
assertType(projects.value?.[0]?.status!);
assertType(projects.value?.[0]?.structure_file!);
assertType<Course>(projects.value?.[0]?.course!);
assertType<SubmissionStatus>(projects.value?.[0]?.status!);
assertType<File>(projects.value?.[0]?.structure_file!);
expect(projects.value?.[0]?.structureChecks).toBe(null);
expect(projects.value?.[0]?.extra_checks).toBe(null);
assertType(Array.isArray(projects.value?.[0]?.groups));
assertType((projects.value?.[0]?.groups?.[0] ?? null)!);
assertType<Group[]>(projects.value?.[0]?.groups!);
expect(projects.value?.[0]?.submissions).toBe(null);

expect(projects.value?.[1]?.name).toBe('project1');
Expand All @@ -89,13 +89,12 @@ describe('project', (): void => {
expect(projects.value?.[1]?.max_score).toBe(50);
expect(projects.value?.[1]?.score_visible).toBe(false);
expect(projects.value?.[1]?.group_size).toBe(8);
assertType(projects.value?.[1]?.course!);
assertType(projects.value?.[1]?.status!);
assertType(projects.value?.[1]?.structure_file!);
assertType<Course>(projects.value?.[1]?.course!);
assertType<SubmissionStatus>(projects.value?.[1]?.status!);
assertType<File>(projects.value?.[1]?.structure_file!);
expect(projects.value?.[1]?.structureChecks).toBe(null);
expect(projects.value?.[1]?.extra_checks).toBe(null);
assertType(Array.isArray(projects.value?.[1]?.groups));
assertType((projects.value?.[0]?.groups?.[1] ?? null)!);
assertType<Group[]>(projects.value?.[1]?.groups!);
expect(projects.value?.[1]?.submissions).toBe(null);
});

Expand All @@ -118,13 +117,12 @@ describe('project', (): void => {
expect(projects.value?.[0]?.max_score).toBe(100);
expect(projects.value?.[0]?.score_visible).toBe(true);
expect(projects.value?.[0]?.group_size).toBe(5);
assertType(projects.value?.[0]?.course!);
assertType(projects.value?.[0]?.status!);
assertType(projects.value?.[0]?.structure_file!);
assertType<Course>(projects.value?.[0]?.course!);
assertType<SubmissionStatus>(projects.value?.[0]?.status!);
assertType<File>(projects.value?.[0]?.structure_file!);
expect(projects.value?.[0]?.structureChecks).toBe(null);
expect(projects.value?.[0]?.extra_checks).toBe(null);
assertType(Array.isArray(projects.value?.[0]?.groups));
assertType((projects.value?.[0]?.groups?.[0] ?? null)!);
assertType<Group[]>(projects.value?.[0]?.groups!);
expect(projects.value?.[0]?.submissions).toBe(null);

expect(projects.value?.[1]?.name).toBe('project1');
Expand All @@ -137,13 +135,12 @@ describe('project', (): void => {
expect(projects.value?.[1]?.max_score).toBe(50);
expect(projects.value?.[1]?.score_visible).toBe(false);
expect(projects.value?.[1]?.group_size).toBe(8);
assertType(projects.value?.[1]?.course!);
assertType(projects.value?.[1]?.status!);
assertType(projects.value?.[1]?.structure_file!);
assertType<Course>(projects.value?.[1]?.course!);
assertType<SubmissionStatus>(projects.value?.[1]?.status!);
assertType<File>(projects.value?.[1]?.structure_file!);
expect(projects.value?.[1]?.structureChecks).toBe(null);
expect(projects.value?.[1]?.extra_checks).toBe(null);
assertType(Array.isArray(projects.value?.[1]?.groups));
assertType((projects.value?.[0]?.groups?.[1] ?? null)!);
assertType<Group[]>(projects.value?.[1]?.groups!);
expect(projects.value?.[1]?.submissions).toBe(null);
});

Expand Down

0 comments on commit d457f69

Please sign in to comment.