@@ -5,16 +5,16 @@ import {
55 PROPERTY_DEPS_METADATA ,
66} from '@nestjs/common/constants' ;
77import { createController } from './create-controller' ;
8- import { JsonBaseController } from '../controllers/json-base.controller' ;
8+ import { Users } from '../mock-utils' ;
9+ import { JsonBaseController } from '../mixin/controller/json-base.controller' ;
910import {
1011 JSON_API_CONTROLLER_POSTFIX ,
11- ORM_SERVICE ,
12- ORM_SERVICE_PROPS ,
13- } from '../../../constants' ;
12+ JSON_API_DECORATOR_ENTITY ,
13+ TYPEORM_SERVICE ,
14+ TYPEORM_SERVICE_PROPS ,
15+ } from '../constants' ;
1416import { InjectService , JsonApi } from '../decorators' ;
15- import { ErrorInterceptors , LogTimeInterceptors } from '../interceptors' ;
16-
17- class Users { }
17+ import { ErrorInterceptors , LogTimeInterceptors } from '../mixin/interceptors' ;
1818
1919describe ( 'createController' , ( ) => {
2020 it ( 'Should be error' , ( ) => {
@@ -49,15 +49,23 @@ describe('createController', () => {
4949 const result = createController ( Users ) ;
5050 const result2 = createController ( Users , TestController ) ;
5151 const result3 = createController ( Users , TestController2 ) ;
52-
5352 expect ( Reflect . getMetadata ( CONTROLLER_WATERMARK , result ) ) . toBe ( true ) ;
5453 expect ( Reflect . getMetadata ( PATH_METADATA , result ) ) . toBe ( 'users' ) ;
54+ expect ( Reflect . getMetadata ( JSON_API_DECORATOR_ENTITY , result ) ) . toEqual (
55+ Users
56+ ) ;
5557
5658 expect ( Reflect . getMetadata ( CONTROLLER_WATERMARK , result2 ) ) . toBe ( true ) ;
5759 expect ( Reflect . getMetadata ( PATH_METADATA , result2 ) ) . toBe ( 'users' ) ;
60+ expect ( Reflect . getMetadata ( JSON_API_DECORATOR_ENTITY , result2 ) ) . toEqual (
61+ Users
62+ ) ;
5863
5964 expect ( Reflect . getMetadata ( CONTROLLER_WATERMARK , result3 ) ) . toBe ( true ) ;
6065 expect ( Reflect . getMetadata ( PATH_METADATA , result3 ) ) . toBe ( overrideRoute ) ;
66+ expect ( Reflect . getMetadata ( JSON_API_DECORATOR_ENTITY , result3 ) ) . toEqual (
67+ Users
68+ ) ;
6169 } ) ;
6270
6371 it ( 'Check inject typeorm, service' , ( ) => {
@@ -84,13 +92,13 @@ describe('createController', () => {
8492 expect ( intecept ) . not . toBe ( undefined ) ;
8593 expect ( intecept [ 0 ] ) . toEqual ( LogTimeInterceptors ) ;
8694 expect ( intecept [ 1 ] ) . toEqual ( ErrorInterceptors ) ;
87- expect ( check [ 0 ] . key ) . toBe ( ORM_SERVICE_PROPS ) ;
88- expect ( check [ 0 ] . type ) . toEqual ( ORM_SERVICE ) ;
95+ expect ( check [ 0 ] . key ) . toBe ( TYPEORM_SERVICE_PROPS ) ;
96+ expect ( check [ 0 ] . type ) . toEqual ( TYPEORM_SERVICE ) ;
8997
9098 expect ( check1 [ 0 ] . key ) . toBe ( 'tmp' ) ;
91- expect ( check1 [ 0 ] . type ) . toEqual ( ORM_SERVICE ) ;
99+ expect ( check1 [ 0 ] . type ) . toEqual ( TYPEORM_SERVICE ) ;
92100
93- expect ( check1 [ 1 ] . key ) . toBe ( ORM_SERVICE_PROPS ) ;
94- expect ( check1 [ 1 ] . type ) . toEqual ( ORM_SERVICE ) ;
101+ expect ( check1 [ 1 ] . key ) . toBe ( TYPEORM_SERVICE_PROPS ) ;
102+ expect ( check1 [ 1 ] . type ) . toEqual ( TYPEORM_SERVICE ) ;
95103 } ) ;
96104} ) ;
0 commit comments