test: cover queues and court rotation and document release test choice
This commit is contained in:
1 parent
1d660a3c40
commit
0757e0df76
10 files changed
+730
-39
No files matched your search
@@ -1,16 +1,56 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { db } from 'db';
|
||||
import { CourtServiceJudgeService } from './court.service.judge.service';
|
||||
|
||||
describe('CourtServiceJudgeService', () => {
|
||||
describe('CourtServiceJudgeService persistence', () => {
|
||||
let service: CourtServiceJudgeService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
beforeEach(async () => {
|
||||
await db.courtServiceJudges.clear();
|
||||
service = TestBed.inject(CourtServiceJudgeService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
afterEach(async () => {
|
||||
TestBed.resetTestingModule();
|
||||
await db.courtServiceJudges.clear();
|
||||
});
|
||||
|
||||
it('saves an assignment and returns its generated ID', async () => {
|
||||
const id = await service.save({ umpireId: 10, courtNo: 2 });
|
||||
expect(await db.courtServiceJudges.get(id)).toEqual({
|
||||
id,
|
||||
umpireId: 10,
|
||||
courtNo: 2
|
||||
});
|
||||
});
|
||||
|
||||
it('updates an assignment without changing its court', async () => {
|
||||
const id = await service.save({ umpireId: 10, courtNo: 2 });
|
||||
expect(await service.update(id, { umpireId: 20 })).toBe(1);
|
||||
expect(await db.courtServiceJudges.get(id)).toEqual({
|
||||
id,
|
||||
umpireId: 20,
|
||||
courtNo: 2
|
||||
});
|
||||
expect(await service.update(id + 100, { umpireId: 30 })).toBe(0);
|
||||
});
|
||||
|
||||
it('deletes only the selected assignment', async () => {
|
||||
const id = await service.save({ umpireId: 10, courtNo: 1 });
|
||||
const retained = await service.save({ umpireId: 20, courtNo: 2 });
|
||||
await service.delete(id);
|
||||
expect(await db.courtServiceJudges.toArray()).toEqual([
|
||||
{ id: retained, umpireId: 20, courtNo: 2 }
|
||||
]);
|
||||
});
|
||||
|
||||
it('removes by official ID while retaining other courts', async () => {
|
||||
await service.save({ umpireId: 10, courtNo: 1 });
|
||||
const id = await service.save({ umpireId: 20, courtNo: 2 });
|
||||
await service.removeByUmpireId(10);
|
||||
await service.removeByUmpireId(999);
|
||||
expect(await db.courtServiceJudges.toArray()).toEqual([
|
||||
{ id, umpireId: 20, courtNo: 2 }
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user