From d457f69ed9503c148c9e69c90ee606e7ecfbf6d9 Mon Sep 17 00:00:00 2001 From: francis Date: Tue, 21 May 2024 18:27:00 +0200 Subject: [PATCH] chore: fix asserttypes --- .../test/unit/services/group_service.test.ts | 24 +++------- .../unit/services/project_service.test.ts | 47 +++++++++---------- 2 files changed, 28 insertions(+), 43 deletions(-) diff --git a/frontend/src/test/unit/services/group_service.test.ts b/frontend/src/test/unit/services/group_service.test.ts index 1935fb74..e36805c9 100644 --- a/frontend/src/test/unit/services/group_service.test.ts +++ b/frontend/src/test/unit/services/group_service.test.ts @@ -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; @@ -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(group.value?.project!); expect(group.value?.students).toBeNull(); expect(group.value?.submissions).toBeNull(); }); @@ -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(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(groups.value?.[1].project!); expect(groups.value?.[1].students).toBeNull; expect(groups.value?.[1].submissions).toBeNull(); }); @@ -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(groups.value?.[0].project!); expect(groups.value?.[0].students).toBeNull; expect(groups.value?.[0].submissions).toBeNull(); }); diff --git a/frontend/src/test/unit/services/project_service.test.ts b/frontend/src/test/unit/services/project_service.test.ts index cc7a7594..5b156dd7 100644 --- a/frontend/src/test/unit/services/project_service.test.ts +++ b/frontend/src/test/unit/services/project_service.test.ts @@ -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'; @@ -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(project.value?.course!); + assertType(project.value?.status!); + assertType(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(project.value?.groups!); expect(project.value?.submissions).toBe(null); }); @@ -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(projects.value?.[0]?.course!); + assertType(projects.value?.[0]?.status!); + assertType(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(projects.value?.[0]?.groups!); expect(projects.value?.[0]?.submissions).toBe(null); expect(projects.value?.[1]?.name).toBe('project1'); @@ -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(projects.value?.[1]?.course!); + assertType(projects.value?.[1]?.status!); + assertType(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(projects.value?.[1]?.groups!); expect(projects.value?.[1]?.submissions).toBe(null); }); @@ -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(projects.value?.[0]?.course!); + assertType(projects.value?.[0]?.status!); + assertType(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(projects.value?.[0]?.groups!); expect(projects.value?.[0]?.submissions).toBe(null); expect(projects.value?.[1]?.name).toBe('project1'); @@ -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(projects.value?.[1]?.course!); + assertType(projects.value?.[1]?.status!); + assertType(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(projects.value?.[1]?.groups!); expect(projects.value?.[1]?.submissions).toBe(null); });