@@ -20,7 +20,7 @@ describe('connectionResolver', () => {
2020 sort : sortOptions ,
2121 } ) ;
2222
23- describe ( 'basic checks' , ( ) => {
23+ describe ( 'definition checks' , ( ) => {
2424 it ( 'should return Resolver' , ( ) => {
2525 expect ( connectionResolver ) . instanceof ( Resolver ) ;
2626 } ) ;
@@ -98,6 +98,63 @@ describe('connectionResolver', () => {
9898 } ) ;
9999 } ) ;
100100
101+ describe ( 'call of findMany resolver' , ( ) => {
102+ let spyResolveParams ;
103+ let mockedConnectionResolver ;
104+
105+ beforeEach ( ( ) => {
106+ const mockedFindMany = userTypeComposer . getResolver ( 'findMany' )
107+ . wrapResolve ( ( next ) => ( resolveParams ) => {
108+ spyResolveParams = resolveParams ;
109+ return next ( resolveParams ) ;
110+ } ) ;
111+ userTypeComposer . setResolver ( 'mockedFindMany' , mockedFindMany ) ;
112+ mockedConnectionResolver = prepareConnectionResolver ( userTypeComposer , {
113+ countResolverName : 'count' ,
114+ findResolverName : 'mockedFindMany' ,
115+ sort : sortOptions ,
116+ } ) ;
117+ } ) ;
118+
119+ it ( 'should pass args.sort' , async ( ) => {
120+ const result = await mockedConnectionResolver . resolve ( {
121+ args : {
122+ sort : { name : 1 } ,
123+ first : 3 ,
124+ } ,
125+ } ) ;
126+ expect ( spyResolveParams ) . have . deep . property ( 'args.sort.name' , 1 ) ;
127+ } ) ;
128+
129+ it ( 'should pass projection edges.node on top level' , async ( ) => {
130+ const result = await mockedConnectionResolver . resolve ( {
131+ args : { } ,
132+ projection : {
133+ edges : {
134+ node : {
135+ name : true ,
136+ age : true ,
137+ }
138+ }
139+ } ,
140+ } ) ;
141+ expect ( spyResolveParams ) . have . deep . property ( 'projection.name' , true ) ;
142+ expect ( spyResolveParams ) . have . deep . property ( 'projection.age' , true ) ;
143+ } ) ;
144+
145+ it ( 'should pass custom projections to top level' , async ( ) => {
146+ const result = await mockedConnectionResolver . resolve ( {
147+ args : { } ,
148+ projection : {
149+ score : { $meta : 'textScore' } ,
150+ } ,
151+ } ) ;
152+ expect ( spyResolveParams ) . have . deep . property ( 'projection.score' ) ;
153+ expect ( spyResolveParams ) . have . deep . property ( 'projection.score' )
154+ . to . deep . equal ( { $meta : 'textScore' } ) ;
155+ } ) ;
156+ } ) ;
157+
101158 describe ( 'prepareRawQuery()' , ( ) => {
102159 const sortConfig = {
103160 value : { id : 1 } ,
0 commit comments