26 lines
1.6 KiB
TypeScript
26 lines
1.6 KiB
TypeScript
import { GoneException } from '@nestjs/common';
|
|
import { ApprovalsController } from './approvals.controller';
|
|
import { PrismaService } from '../prisma/prisma.service';
|
|
|
|
describe('ApprovalsController 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 ApprovalsController(prisma as PrismaService);
|
|
beforeEach(()=>access.mockClear());
|
|
it('create {department:SEO,category:SEO,title:Legacy,payload:{}} returns 410 without reading or writing persistence',async()=>{
|
|
await expect(controller.create({department:'SEO',category:'SEO',title:'Legacy',payload:{}})).rejects.toBeInstanceOf(GoneException);
|
|
await expect(controller.create({department:'SEO',category:'SEO',title:'Legacy',payload:{}})).rejects.toMatchObject({status:410});
|
|
expect(access).not.toHaveBeenCalled();
|
|
});
|
|
it('decide missing, {decision:APPROVED} returns 410 without reading or writing persistence',async()=>{
|
|
await expect(controller.decide('missing', {decision:'APPROVED'})).rejects.toBeInstanceOf(GoneException);
|
|
await expect(controller.decide('missing', {decision:'APPROVED'})).rejects.toMatchObject({status:410});
|
|
expect(access).not.toHaveBeenCalled();
|
|
});
|
|
it('decide missing, {decision:REJECTED} returns 410 without reading or writing persistence',async()=>{
|
|
await expect(controller.decide('missing', {decision:'REJECTED'})).rejects.toBeInstanceOf(GoneException);
|
|
await expect(controller.decide('missing', {decision:'REJECTED'})).rejects.toMatchObject({status:410});
|
|
expect(access).not.toHaveBeenCalled();
|
|
});
|
|
});
|