/
githubmirror
/
nest
Обзор
Документация
Войти
/
githubmirror
/
nest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
sample/31-graphql-federation-code-first/posts-application/src/posts/posts.service.spec.ts
39 строк
981 B
soudai-s
sample(31): align method naming with its behavior
15 окт 2021, 07:01
15 окт 2021, 07:01
572fcc4
Код
Авторство
О чём код?
import { Test, TestingModule } from '@nestjs/testing'; import { PostsService } from './posts.service'; describe('PostsService', () => { let service: PostsService; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ providers: [PostsService], }).compile(); service = module.get<PostsService>(PostsService); }); it('should be defined', () => { expect(service).toBeDefined(); }); it('should get all posts for an author', () => { const result = service.findAllByAuthorId(1); expect(result).toEqual( expect.arrayContaining([ expect.objectContaining({ authorId: 1, }), ]), ); }); it('should get a single post using the id', () => { const result = service.findOne(1); expect(result.id).toEqual(1); }); it('should get all posts', () => { const result = service.findAll(); expect(result.length).toEqual(service['posts'].length); }); });