fix: lint
This commit is contained in:
parent
2d841e7955
commit
3a78710059
4 changed files with 25 additions and 42 deletions
|
@ -2,13 +2,14 @@ import { setupTestApp } from '../setup-tests.js';
|
|||
import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest';
|
||||
import { Request, Response } from 'express';
|
||||
import { getAssignmentHandler, getAllAssignmentsHandler, getAssignmentsSubmissionsHandler } from '../../src/controllers/assignments.js';
|
||||
import { checkReturn404, checkReturnList } from './qol.js'
|
||||
import {getAnswerHandler} from "../../src/controllers/answers";
|
||||
import { NotFoundException } from "../../src/exceptions/not-found-exception";
|
||||
import {getClass01, getClass02, getClass03} from "../test_assets/classes/classes.testdata";
|
||||
import { getClass01 } from "../test_assets/classes/classes.testdata";
|
||||
import { getAssignment01 } from "../test_assets/assignments/assignments.testdata";
|
||||
|
||||
function createRequestObject(classid: string, assignmentid: string) {
|
||||
function createRequestObject(classid: string, assignmentid: string): {
|
||||
query: {};
|
||||
params: { classid: string; id: string }
|
||||
} {
|
||||
return {
|
||||
params: {
|
||||
classid: classid,
|
||||
|
@ -40,7 +41,7 @@ describe('Assignment controllers', () => {
|
|||
});
|
||||
|
||||
it('return error non-existing assignment', async () => {
|
||||
req = createRequestObject('doesnotexist', '43000'); // should not exist
|
||||
req = createRequestObject('doesnotexist', '43000'); // Should not exist
|
||||
|
||||
await expect(async () => getAssignmentHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException);
|
||||
});
|
||||
|
|
|
@ -8,7 +8,6 @@ import {
|
|||
getGroupHandler,
|
||||
getGroupSubmissionsHandler
|
||||
} from '../../src/controllers/groups.js';
|
||||
import {getAnswerHandler} from "../../src/controllers/answers";
|
||||
import { NotFoundException } from "../../src/exceptions/not-found-exception";
|
||||
import { getClass01 } from "../test_assets/classes/classes.testdata";
|
||||
import { getAssignment01, getAssignment02 } from "../test_assets/assignments/assignments.testdata";
|
||||
|
@ -51,7 +50,7 @@ describe('Group controllers', () => {
|
|||
params: {
|
||||
classid: 'id01',
|
||||
assignmentid: '1',
|
||||
groupid: '154981', // should not exist
|
||||
groupid: '154981', // Should not exist
|
||||
},
|
||||
query: {},
|
||||
};
|
||||
|
@ -64,8 +63,8 @@ describe('Group controllers', () => {
|
|||
req = {
|
||||
params: {
|
||||
classid: 'id01',
|
||||
assignmentid: '1000', // should not exist
|
||||
groupid: '42000', // should not exist
|
||||
assignmentid: '1000', // Should not exist
|
||||
groupid: '42000', // Should not exist
|
||||
},
|
||||
query: {},
|
||||
};
|
||||
|
@ -76,9 +75,9 @@ describe('Group controllers', () => {
|
|||
it('should return 404 not found ont a non-existing class', async () => {
|
||||
req = {
|
||||
params: {
|
||||
classid: 'doesnotexist', // should not exist
|
||||
assignmentid: '1000', // should not exist
|
||||
groupid: '42000', // should not exist
|
||||
classid: 'doesnotexist', // Should not exist
|
||||
assignmentid: '1000', // Should not exist
|
||||
groupid: '42000', // Should not exist
|
||||
},
|
||||
query: {},
|
||||
};
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
export function checkReturnList(jsonMock: Mock, listName: string, length?: number) {
|
||||
expect(jsonMock).toHaveBeenCalled();
|
||||
|
||||
const result = jsonMock.mock.lastCall![0];
|
||||
|
||||
expect(listName in result).toBeTruthy();
|
||||
|
||||
if (length) {
|
||||
expect(result[listName].length).toBe(length);
|
||||
}
|
||||
}
|
||||
|
||||
export function checkReturn404(jsonMock: Mock, statusMock: Mock) {
|
||||
expect(statusMock).toHaveBeenCalledWith(404);
|
||||
expect(jsonMock).toHaveBeenCalled();
|
||||
}
|
|
@ -1,16 +1,15 @@
|
|||
import { setupTestApp } from '../setup-tests.js';
|
||||
import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest';
|
||||
import {
|
||||
getSubmissionHandler,
|
||||
getAllSubmissionsHandler,
|
||||
deleteSubmissionHandler, createSubmissionHandler
|
||||
} from '../../src/controllers/submissions.js';
|
||||
import { getSubmissionHandler, getAllSubmissionsHandler } from '../../src/controllers/submissions.js';
|
||||
import { Request, Response } from 'express';
|
||||
import { NotFoundException } from "../../src/exceptions/not-found-exception";
|
||||
import {getClass01, getClass02} from "../test_assets/classes/classes.testdata";
|
||||
import { getClass02 } from "../test_assets/classes/classes.testdata";
|
||||
|
||||
|
||||
function createRequestObject(hruid: string, submissionNumber: string) {
|
||||
function createRequestObject(hruid: string, submissionNumber: string): {
|
||||
query: { language: string; version: string };
|
||||
params: { hruid: string; id: string }
|
||||
} {
|
||||
return {
|
||||
params: {
|
||||
hruid: hruid,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue