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'
2
2
import Context from "app/common/context" ;
3
3
import { recordGraphQLRequest } from "../support/helpers" ;
4
4
@@ -115,7 +115,7 @@ query User($id: ID!) {
115
115
} ) ;
116
116
} ) ;
117
117
118
- describe ( 'without ID but with filter' , ( ) => {
118
+ describe ( 'without ID but with filter with ID ' , ( ) => {
119
119
it ( 'sends the correct query to the API' , async ( ) => {
120
120
const request = await recordGraphQLRequest ( async ( ) => {
121
121
await User . fetch ( { profileId : 2 } ) ;
@@ -141,6 +141,43 @@ query Users($profileId: ID!) {
141
141
} ) ;
142
142
} ) ;
143
143
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
+
144
181
describe ( 'without ID or filter' , ( ) => {
145
182
it ( 'sends the correct query to the API' , async ( ) => {
146
183
const request = await recordGraphQLRequest ( async ( ) => { await User . fetch ( ) ; } ) ;
0 commit comments