File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,28 @@ describe('updateById() ->', () => {
129129 expect ( result ) . have . deep . property ( 'record.id' , user1 . id ) ;
130130 expect ( result ) . have . deep . property ( 'record.name' , checkedName ) ;
131131 } ) ;
132+
133+ it ( 'should extract projection from record for findById' , async ( ) => {
134+ const checkedName = 'anyName123' ;
135+ const result = await updateById ( UserModel , UserTypeComposer ) . resolve ( {
136+ args : {
137+ record : {
138+ _id : user1 . id ,
139+ name : checkedName ,
140+ } ,
141+ } ,
142+ projection : {
143+ record : {
144+ name : true ,
145+ gender : true ,
146+ } ,
147+ skills : true ,
148+ } ,
149+ } ) ;
150+ expect ( result ) . have . deep . property ( 'record.id' , user1 . id ) ;
151+ expect ( result ) . have . deep . property ( 'record.gender' ) ;
152+ expect ( result ) . not . have . deep . property ( 'record.skills' ) ;
153+ } ) ;
132154 } ) ;
133155
134156 describe ( 'Resolver.getOutputType()' , ( ) => {
Original file line number Diff line number Diff line change @@ -157,6 +157,24 @@ describe('updateOne() ->', () => {
157157 } ) ;
158158 expect ( result1 . record . id ) . to . not . equal ( result2 . record . id ) ;
159159 } ) ;
160+
161+ it ( 'should extract projection from record for findOne' , async ( ) => {
162+ const result = await updateOne ( UserModel , UserTypeComposer ) . resolve ( {
163+ args : {
164+ filter : { _id : user1 . id } ,
165+ } ,
166+ projection : {
167+ record : {
168+ name : true ,
169+ gender : true ,
170+ } ,
171+ skills : true ,
172+ } ,
173+ } ) ;
174+ expect ( result ) . have . deep . property ( 'record.id' , user1 . id ) ;
175+ expect ( result ) . have . deep . property ( 'record.gender' ) ;
176+ expect ( result ) . not . have . deep . property ( 'record.skills' ) ;
177+ } ) ;
160178 } ) ;
161179
162180 describe ( 'Resolver.getOutputType()' , ( ) => {
You can’t perform that action at this time.
0 commit comments