Skip to content

Commit

Permalink
chore: fix linting, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
francisvaut committed Apr 5, 2024
1 parent 178cf4e commit be57c37
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/frontend-linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
linting-checks:
runs-on: ubuntu-latest
steps:
- name: Add permission to remove contents of previous action script
run: echo ${{ secrets.SUDO }} | sudo -S chown -R $USER:$USER /home/selab2/actions-runner/_work/UGent-7/
- uses: actions/checkout@v4
- name: Install dependencies
run: cd frontend; npm install
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/test/unit/admin_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('admin', (): void => {
await getAdmins();
expect(admins).not.toBeNull();
expect(Array.isArray(admins.value)).toBe(true);
expect(admins.value?.length).toBe(3);
expect(admins.value?.length).toBe(2);

expect(admins.value?.[0]?.username).toBe('tverslyp');
expect(admins.value?.[0]?.is_staff).toBe(true);
Expand Down Expand Up @@ -73,10 +73,10 @@ describe('admin', (): void => {
await getAdmins();
expect(admins).not.toBeNull();
expect(Array.isArray(admins.value)).toBe(true);
const prevLength = admins.value?.length || 0;
const prevLength = admins.value?.length ?? 0;

await createAdmin(exampleAdmin);
await getAdmins()
await getAdmins();

expect(admins).not.toBeNull();
expect(Array.isArray(admins.value)).toBe(true);
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/test/unit/assistant_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ describe('assistant', (): void => {
[],
[],
new Date('April 2, 2023 01:15:00'),
new Date('April 2, 2024 01:15:00')
new Date('April 2, 2024 01:15:00'),
);

await getAssistants();
expect(assistants).not.toBeNull();
expect(Array.isArray(assistants.value)).toBe(true);
const prevLength = assistants.value?.length || 0;
const prevLength = assistants.value?.length ?? 0;

await createAssistant(exampleAssistant);
await getAssistants()
await getAssistants();

expect(assistants).not.toBeNull();
expect(Array.isArray(assistants.value)).toBe(true);
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/test/unit/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { afterAll, afterEach, beforeAll } from 'vitest';
import { setupServer } from 'msw/node';
import { HttpResponse, http } from 'msw';
Expand All @@ -6,7 +7,6 @@ import { createPinia } from 'pinia';

import { endpoints } from '@/config/endpoints.ts';
import { JSDOM } from 'jsdom';
import { Student } from '@/types/users/Student';

const baseUrl = 'http://localhost';

Expand Down Expand Up @@ -147,7 +147,10 @@ const courses = [
},
];

const faculties = [{ id: 'sciences', name: 'wetenschappen' }, { id:'football', name: 'voetbal' }];
const faculties = [
{ id: 'sciences', name: 'wetenschappen' },
{ id: 'football', name: 'voetbal' },
];

const students = [
{
Expand Down Expand Up @@ -494,7 +497,7 @@ export const restHandlers = [
const buffer = await request.arrayBuffer();
const requestBody = new TextDecoder().decode(buffer);
const newAssistant = JSON.parse(requestBody);
newAssistant.roles = ['assistant']
newAssistant.roles = ['assistant'];
assistants.push(newAssistant);
return HttpResponse.json(assistants);
}),
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/test/unit/student_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,29 +161,29 @@ describe('students', (): void => {

it('create student', async () => {
const exampleStudent = new Student(
"103",
"sample_student",
"[email protected]",
"Sample",
"Student",
'103',
'sample_student',
'[email protected]',
'Sample',
'Student',
false,
2024,
new Date('April 2, 2023 01:15:00'),
new Date('April 2, 2024 01:15:00'),
"12345",
'12345',
['student'],
[],
[],
[]
[],
);

await getStudents();
expect(students).not.toBeNull();
expect(Array.isArray(students.value)).toBe(true);
const prevLength = students.value?.length || 0;
const prevLength = students.value?.length ?? 0;

await createStudent(exampleStudent);
await getStudents()
await getStudents();

expect(students).not.toBeNull();
expect(Array.isArray(students.value)).toBe(true);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/types/Faculty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export class Faculty {
* @param faculty
*/
static fromJSON(faculty: Faculty): Faculty {
console.log(JSON.stringify(faculty))
return new Faculty(faculty.id, faculty.name);
}
}

0 comments on commit be57c37

Please sign in to comment.