@@ -17,6 +17,7 @@ import {
1717 UpdateEntityPermissionInput ,
1818} from '../../../src/schema/graphql.schema' ;
1919import { mockedConfigService } from '../../utils/mocks/config.service' ;
20+ import EntityModel from '../../../src/authorization/entity/entity.entity' ;
2021
2122const gql = '/graphql' ;
2223
@@ -46,15 +47,13 @@ const allEntities: Entity[] = [
4647 id : '2b33268a-7ff5-4cac-a87a-6bfc4430d34c' ,
4748 name : 'Customers' ,
4849 permissions : permissions ,
49- tenantId : '1ef2a357-d4b7-4a30-88ca-d1cc627f2994' ,
5050 } ,
5151] ;
5252
5353const entities : Entity [ ] = [
5454 {
5555 id : '2b33268a-7ff5-4cac-a87a-6bfc4430d34c' ,
5656 name : 'Customers' ,
57- tenantId : '1ef2a357-d4b7-4a30-88ca-d1cc627f2994' ,
5857 } ,
5958] ;
6059
@@ -94,15 +93,17 @@ describe('Entity Module', () => {
9493 describe ( gql , ( ) => {
9594 describe ( 'entities' , ( ) => {
9695 it ( 'should get the entities' , ( ) => {
97- entityService . getAllEntities ( ) . returns ( Promise . resolve ( entities ) ) ;
96+ entityService
97+ . getAllEntities ( )
98+ . returns ( Promise . resolve ( entities as EntityModel [ ] ) ) ;
9899 entityService
99100 . getEntityPermissions ( '2b33268a-7ff5-4cac-a87a-6bfc4430d34c' )
100101 . returns ( Promise . resolve ( permissions ) ) ;
101102 return request ( app . getHttpServer ( ) )
102103 . post ( gql )
103104 . set ( 'Authorization' , `Bearer ${ token } ` )
104105 . send ( {
105- query : '{getEntities {id name permissions { id name} tenantId }}' ,
106+ query : '{getEntities {id name permissions { id name}}}' ,
106107 } )
107108 . expect ( 200 )
108109 . expect ( ( res ) => {
@@ -113,13 +114,13 @@ describe('Entity Module', () => {
113114 it ( 'should get single entity' , ( ) => {
114115 entityService
115116 . getEntityById ( 'ae032b1b-cc3c-4e44-9197-276ca877a7f8' )
116- . returns ( Promise . resolve ( entities [ 0 ] ) ) ;
117+ . returns ( Promise . resolve ( entities [ 0 ] as EntityModel ) ) ;
117118 return request ( app . getHttpServer ( ) )
118119 . post ( gql )
119120 . set ( 'Authorization' , `Bearer ${ token } ` )
120121 . send ( {
121122 query :
122- '{getEntity(id: "ae032b1b-cc3c-4e44-9197-276ca877a7f8") {id name tenantId }}' ,
123+ '{getEntity(id: "ae032b1b-cc3c-4e44-9197-276ca877a7f8") {id name}}' ,
123124 } )
124125 . expect ( 200 )
125126 . expect ( ( res ) => {
@@ -134,13 +135,12 @@ describe('Entity Module', () => {
134135 const obj = Object . create ( null ) ;
135136 entityService
136137 . createEntity ( Object . assign ( obj , input ) )
137- . returns ( Promise . resolve ( entities [ 0 ] ) ) ;
138+ . returns ( Promise . resolve ( entities [ 0 ] as EntityModel ) ) ;
138139 return request ( app . getHttpServer ( ) )
139140 . post ( gql )
140141 . set ( 'Authorization' , `Bearer ${ token } ` )
141142 . send ( {
142- query :
143- 'mutation { createEntity(input: {name: "Test1"}) {id name tenantId}}' ,
143+ query : 'mutation { createEntity(input: {name: "Test1"}) {id name}}' ,
144144 } )
145145 . expect ( 200 )
146146 . expect ( ( res ) => {
@@ -158,13 +158,13 @@ describe('Entity Module', () => {
158158 'ae032b1b-cc3c-4e44-9197-276ca877a7f8' ,
159159 Object . assign ( obj , input ) ,
160160 )
161- . returns ( Promise . resolve ( entities [ 0 ] ) ) ;
161+ . returns ( Promise . resolve ( entities [ 0 ] as EntityModel ) ) ;
162162 return request ( app . getHttpServer ( ) )
163163 . post ( gql )
164164 . set ( 'Authorization' , `Bearer ${ token } ` )
165165 . send ( {
166166 query :
167- 'mutation { updateEntity(id: "ae032b1b-cc3c-4e44-9197-276ca877a7f8", input: {name: "Test1"}) {id name tenantId }}' ,
167+ 'mutation { updateEntity(id: "ae032b1b-cc3c-4e44-9197-276ca877a7f8", input: {name: "Test1"}) {id name}}' ,
168168 } )
169169 . expect ( 200 )
170170 . expect ( ( res ) => {
@@ -175,13 +175,13 @@ describe('Entity Module', () => {
175175 it ( 'should delete a entity' , ( ) => {
176176 entityService
177177 . deleteEntity ( 'ae032b1b-cc3c-4e44-9197-276ca877a7f8' )
178- . returns ( Promise . resolve ( entities [ 0 ] ) ) ;
178+ . returns ( Promise . resolve ( entities [ 0 ] as EntityModel ) ) ;
179179 return request ( app . getHttpServer ( ) )
180180 . post ( gql )
181181 . set ( 'Authorization' , `Bearer ${ token } ` )
182182 . send ( {
183183 query :
184- 'mutation { deleteEntity(id: "ae032b1b-cc3c-4e44-9197-276ca877a7f8") {id name tenantId }}' ,
184+ 'mutation { deleteEntity(id: "ae032b1b-cc3c-4e44-9197-276ca877a7f8") {id name}}' ,
185185 } )
186186 . expect ( 200 )
187187 . expect ( ( res ) => {
0 commit comments