test: class repository is getest

This commit is contained in:
Laure Jablonski 2025-03-08 11:48:50 +01:00
parent 8f0a76f4e6
commit 127088ea00
2 changed files with 125 additions and 30 deletions

View 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();
});
});