1- import { setupMockData , User , Video , Post , Comment , TariffTariffOption , Tariff , TariffOption } from 'test/support/mock-data'
1+ import { setupMockData , User , Profile , Video , Post , Comment , TariffTariffOption , Tariff , TariffOption } from 'test/support/mock-data'
22import Context from "app/common/context" ;
33import { recordGraphQLRequest } from "../support/helpers" ;
44
@@ -115,7 +115,7 @@ query User($id: ID!) {
115115 } ) ;
116116 } ) ;
117117
118- describe ( 'without ID but with filter' , ( ) => {
118+ describe ( 'without ID but with filter with ID ' , ( ) => {
119119 it ( 'sends the correct query to the API' , async ( ) => {
120120 const request = await recordGraphQLRequest ( async ( ) => {
121121 await User . fetch ( { profileId : 2 } ) ;
@@ -141,6 +141,43 @@ query Users($profileId: ID!) {
141141 } ) ;
142142 } ) ;
143143
144+ describe ( 'without ID but with filter with object' , ( ) => {
145+ it ( 'sends the correct query to the API' , async ( ) => {
146+ await Profile . fetch ( 2 ) ;
147+ const profile = Context . getInstance ( ) . getModel ( 'profile' ) . getRecordWithId ( 2 ) ;
148+
149+ const request = await recordGraphQLRequest ( async ( ) => {
150+ await User . fetch ( { profile } ) ;
151+ } ) ;
152+
153+ expect ( request . variables ) . toEqual ( {
154+ profile : {
155+ id : profile . id ,
156+ email : profile . email ,
157+ age : profile . age ,
158+ sex : profile . sex ,
159+ }
160+ } ) ;
161+
162+ expect ( request . query ) . toEqual ( `
163+ query Users($profile: ProfileInput!) {
164+ users(filter: {profile: $profile}) {
165+ nodes {
166+ id
167+ name
168+ profile {
169+ id
170+ email
171+ age
172+ sex
173+ }
174+ }
175+ }
176+ }
177+ ` . trim ( ) + "\n" ) ;
178+ } ) ;
179+ } ) ;
180+
144181 describe ( 'without ID or filter' , ( ) => {
145182 it ( 'sends the correct query to the API' , async ( ) => {
146183 const request = await recordGraphQLRequest ( async ( ) => { await User . fetch ( ) ; } ) ;
0 commit comments