test: class repository is getest
This commit is contained in:
parent
8f0a76f4e6
commit
127088ea00
2 changed files with 125 additions and 30 deletions
34
backend/tests/data/classes.test.ts
Normal file
34
backend/tests/data/classes.test.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { beforeAll, describe, expect, it } from 'vitest';
|
||||
import { ClassRepository } from '../../src/data/classes/class-repository';
|
||||
import { setupTestApp } from '../setup-tests';
|
||||
import { getClassRepository } from '../../src/data/repositories';
|
||||
|
||||
describe('ClassRepository', () => {
|
||||
let ClassRepository: ClassRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
ClassRepository = getClassRepository();
|
||||
});
|
||||
|
||||
it('should return nothing because id does not exist', async () => {
|
||||
const classVar = await ClassRepository.findById('id');
|
||||
|
||||
expect(classVar).toBeNull();
|
||||
});
|
||||
|
||||
it('should return requested class', async () => {
|
||||
const classVar = await ClassRepository.findById('class_id01');
|
||||
|
||||
expect(classVar).toBeTruthy();
|
||||
expect(classVar?.displayName).toBe('class01');
|
||||
});
|
||||
|
||||
it('class should be gone after deletion', async () => {
|
||||
await ClassRepository.deleteById('class_id01');
|
||||
|
||||
const classVar = await ClassRepository.findById('class_id01');
|
||||
|
||||
expect(classVar).toBeNull();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue