Files
canina/backend/src/admin/department-tasks.controller.spec.ts
T

26 lines
1.6 KiB
TypeScript

import { GoneException } from '@nestjs/common';
import { DepartmentTasksController } from './department-tasks.controller';
import { PrismaService } from '../prisma/prisma.service';
describe('DepartmentTasksController retired mutation boundary',()=>{
const access=jest.fn();
const prisma=new Proxy({},{get:(_target,key)=>{access(key);throw new Error('Database access forbidden');}});
const controller=new DepartmentTasksController(prisma as PrismaService);
beforeEach(()=>access.mockClear());
it('create {department:SEO,title:Legacy} returns 410 without reading or writing persistence',async()=>{
await expect(controller.create({department:'SEO',title:'Legacy'})).rejects.toBeInstanceOf(GoneException);
await expect(controller.create({department:'SEO',title:'Legacy'})).rejects.toMatchObject({status:410});
expect(access).not.toHaveBeenCalled();
});
it('updateStatus missing, {status:DONE} returns 410 without reading or writing persistence',async()=>{
await expect(controller.updateStatus('missing', {status:'DONE'})).rejects.toBeInstanceOf(GoneException);
await expect(controller.updateStatus('missing', {status:'DONE'})).rejects.toMatchObject({status:410});
expect(access).not.toHaveBeenCalled();
});
it('updateStatus missing, {status:TODO} returns 410 without reading or writing persistence',async()=>{
await expect(controller.updateStatus('missing', {status:'TODO'})).rejects.toBeInstanceOf(GoneException);
await expect(controller.updateStatus('missing', {status:'TODO'})).rejects.toMatchObject({status:410});
expect(access).not.toHaveBeenCalled();
});
});