Advertisement
Guest User

Untitled

a guest
Sep 5th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import { Test } from '@nestjs/testing';
  2. import { ShowController } from './show.controller';
  3. import { ShowService } from './show.service';
  4.  
  5. describe('ShowController', () => {
  6. let showController: ShowController;
  7. let showService: ShowService;
  8.  
  9. beforeEach(async () => {
  10. const module = await Test.createTestingModule({
  11. controllers: [ShowController],
  12. providers: [ShowService],
  13. }).compile();
  14.  
  15. showService = module.get<ShowService>(ShowService);
  16. showController = module.get<ShowController>(ShowController);
  17. });
  18.  
  19. describe('showIndex', () => {
  20. it('should return an array of shows', async () => {
  21. const result = [{ id: 1, name: 'Orange is the new black', episode: [] }];
  22. jest.spyOn(showService, 'showIndex')
  23. .mockImplementation(() => Promise.resolve(result));
  24.  
  25. expect(await showController.showIndex()).toBe(result);
  26.  
  27. });
  28. });
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement