myfreight-assessment/tests/shipments/shipments.controller.spec.ts

37 lines
1.0 KiB
TypeScript

import { Test, TestingModule } from '@nestjs/testing';
import { ShipmentsController } from '@/shipments/shipments.controller';
import { ShipmentsService } from '@/shipments/shipments.service';
describe('ShipmentsController', () => {
let controller: ShipmentsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ShipmentsController],
})
.useMocker((token) => {
if (token === ShipmentsService) {
return {
getAll: jest.fn().mockResolvedValue([]),
};
}
})
.compile();
controller = module.get<ShipmentsController>(ShipmentsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
it('should have a method getShipments', () => {
expect(controller.getShipments).toBeDefined();
});
it('should return an object with message: ok', async () => {
await expect(controller.getShipments()).resolves.toEqual({ data: [] });
});
});