/
githubmirror
/
nest
Обзор
Документация
Войти
/
githubmirror
/
nest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
sample/25-dynamic-modules/src/app.controller.spec.ts
34 строки
929 B
Livio
sample(25): Fix unit tests
23 окт 2019, 21:52
Не верифицирован
23 окт 2019, 21:52
5f33651
Код
Авторство
О чём код?
import { Test, TestingModule } from '@nestjs/testing'; import { AppController } from './app.controller'; import { AppService } from './app.service'; const appServiceMock = { getHello: jest.fn().mockImplementation(() => 'Hello World!'), }; describe('AppController', () => { let appController: AppController; let appService: AppService; beforeEach(async () => { const app: TestingModule = await Test.createTestingModule({ controllers: [AppController], providers: [ { provide: AppService, useValue: appServiceMock, }, ], }).compile(); appService = app.get<AppService>(AppService); appController = app.get<AppController>(AppController); }); describe('root', () => { it('should return "Hello World!"', () => { expect(appController.getHello()).toBe('Hello World!'); expect(appService.getHello).toHaveBeenCalled(); }); }); });