1+ import { ParseService } from "@tsed/common" ;
2+ import { inject } from "@tsed/testing" ;
13import { UserRepositoryToken } from '../../../api/show/show.model' ;
2- import { getInjectionService } from '../../utils/tests/injectors' ;
34import { TvMazeService } from './tvmaze.service' ;
45
56describe ( 'UserService' , ( ) => {
6- it ( 'should fetch user by id' , async ( ) => {
7- const inject = await getInjectionService ( this ) ;
8- const locals = new Map ( ) ;
9- const userData = { name : 'test' } ;
10- const findSpy = jest . fn ( ) . mockReturnValue ( Promise . resolve ( userData ) ) ;
11- locals . set ( UserRepositoryToken , {
12- findById : findSpy
13- } ) ;
7+ let service ;
148
15- const service = inject . invoke < TvMazeService > ( TvMazeService , locals ) ;
16- const foundUser = await service . getShowById ( '123' ) ;
9+ beforeEach ( inject ( [ TvMazeService ] , ( _tvmazeService_ : TvMazeService ) => {
10+ service = _tvmazeService_ ;
11+ } ) ) ;
1712
18- expect ( foundUser ) . toBeDefined ( ) ;
19- // expect(foundUser).toEqual(userData);
20- // expect(findSpy).toHaveBeenCalledTimes(1);
21- // expect(findSpy.mock.calls[0][0]).toBe('123');
13+ it ( 'should fetch show by id' , async ( ) => {
14+ const foundShow = await service . getShowById ( '123' ) ;
15+ expect ( foundShow ) . toHaveProperty ( 'id' ) ;
16+ expect ( foundShow ) . toHaveProperty ( 'url' ) ;
17+ expect ( foundShow ) . toHaveProperty ( 'name' ) ;
18+ expect ( foundShow ) . toHaveProperty ( 'type' ) ;
19+ expect ( foundShow ) . toHaveProperty ( 'language' ) ;
20+ expect ( foundShow ) . toHaveProperty ( 'genres' ) ;
21+ expect ( foundShow ) . toHaveProperty ( 'status' ) ;
22+ expect ( foundShow ) . toHaveProperty ( 'runtime' ) ;
23+ expect ( foundShow ) . toHaveProperty ( 'premiered' ) ;
24+ expect ( foundShow ) . toHaveProperty ( 'officialSite' ) ;
25+ expect ( foundShow ) . toHaveProperty ( 'schedule' ) ;
26+ expect ( foundShow ) . toHaveProperty ( 'rating' ) ;
27+ expect ( foundShow ) . toHaveProperty ( 'weight' ) ;
28+ expect ( foundShow ) . toHaveProperty ( 'network' ) ;
29+ expect ( foundShow ) . toHaveProperty ( 'webChannel' ) ;
30+ expect ( foundShow ) . toHaveProperty ( 'externals' ) ;
31+ expect ( foundShow ) . toHaveProperty ( 'image' ) ;
32+ expect ( foundShow ) . toHaveProperty ( 'summary' ) ;
33+ expect ( foundShow ) . toHaveProperty ( 'updated' ) ;
34+ expect ( foundShow ) . toHaveProperty ( '_links' ) ;
2235 } ) ;
23- } ) ;
36+ } ) ;
0 commit comments