@@ -187,33 +187,66 @@ export function hasManyInclusionResolverAcceptance(
187
187
expect ( toJSON ( result ) ) . to . deepEqual ( toJSON ( expected ) ) ;
188
188
} ) ;
189
189
190
- skipIf (
191
- features . hasRevisionToken ,
192
- it ,
193
- 'returns inclusions after running save() operation' ,
194
- async ( ) => {
195
- // this shows save() works well with func ensurePersistable and ObjectId
196
- // the test skips for Cloudant as it needs the _rev property for replacement.
197
- // see replace-by-id.suite.ts
198
- const thor = await customerRepo . create ( { name : 'Thor' } ) ;
199
- const odin = await customerRepo . create ( { name : 'Odin' } ) ;
200
-
201
- const thorOrder = await orderRepo . create ( {
202
- customerId : thor . id ,
203
- description : 'Pizza' ,
204
- } ) ;
205
-
206
- const pizza = await orderRepo . findById ( thorOrder . id ) ;
207
- pizza . customerId = odin . id ;
208
-
209
- await orderRepo . save ( pizza ) ;
210
- const odinPizza = await orderRepo . findById ( thorOrder . id ) ;
211
-
212
- const result = await customerRepo . findById ( odin . id , {
213
- include : [ { relation : 'orders' } ] ,
214
- } ) ;
215
- const expected = {
216
- ...odin ,
190
+ it ( 'returns inclusions after running save() operation' , async ( ) => {
191
+ // this shows save() works well with func ensurePersistable and ObjectId
192
+ // the test skips for Cloudant as it needs the _rev property for replacement.
193
+ // see replace-by-id.suite.ts
194
+ const thor = await customerRepo . create ( { name : 'Thor' } ) ;
195
+ const odin = await customerRepo . create ( { name : 'Odin' } ) ;
196
+
197
+ const thorOrder = await orderRepo . create ( {
198
+ customerId : thor . id ,
199
+ description : 'Pizza' ,
200
+ } ) ;
201
+
202
+ const pizza = await orderRepo . findById ( thorOrder . id ) ;
203
+ pizza . customerId = odin . id ;
204
+
205
+ await orderRepo . save ( pizza ) ;
206
+ const odinPizza = await orderRepo . findById ( thorOrder . id ) ;
207
+
208
+ const result = await customerRepo . findById ( odin . id , {
209
+ include : [ { relation : 'orders' } ] ,
210
+ } ) ;
211
+ const expected = {
212
+ ...odin ,
213
+ parentId : features . emptyValue ,
214
+ orders : [
215
+ {
216
+ ...odinPizza ,
217
+ isShipped : features . emptyValue ,
218
+ // eslint-disable-next-line @typescript-eslint/camelcase
219
+ shipment_id : features . emptyValue ,
220
+ } ,
221
+ ] ,
222
+ } ;
223
+ expect ( toJSON ( result ) ) . to . containEql ( toJSON ( expected ) ) ;
224
+ } ) ;
225
+
226
+ it ( 'returns inclusions after running replaceById() operation' , async ( ) => {
227
+ // this shows replaceById() works well with func ensurePersistable and ObjectId
228
+ // the test skips for Cloudant as it needs the _rev property for replacement.
229
+ // see replace-by-id.suite.ts
230
+ const thor = await customerRepo . create ( { name : 'Thor' } ) ;
231
+
232
+ const thorOrder = await orderRepo . create ( {
233
+ customerId : thor . id ,
234
+ description : 'Pizza' ,
235
+ } ) ;
236
+
237
+ const pizza = await orderRepo . findById ( thorOrder . id . toString ( ) ) ;
238
+ const reheatedPizza = { ...pizza } ;
239
+ reheatedPizza . description = 'Reheated pizza' ;
240
+
241
+ await orderRepo . replaceById ( thorOrder . id , reheatedPizza ) ;
242
+ const odinPizza = await orderRepo . findById ( thorOrder . id ) ;
243
+
244
+ const result = await customerRepo . find ( {
245
+ include : [ { relation : 'orders' } ] ,
246
+ } ) ;
247
+ const expected = [
248
+ {
249
+ ...thor ,
217
250
parentId : features . emptyValue ,
218
251
orders : [
219
252
{
@@ -223,53 +256,10 @@ export function hasManyInclusionResolverAcceptance(
223
256
shipment_id : features . emptyValue ,
224
257
} ,
225
258
] ,
226
- } ;
227
- expect ( toJSON ( result ) ) . to . containEql ( toJSON ( expected ) ) ;
228
- } ,
229
- ) ;
230
-
231
- skipIf (
232
- features . hasRevisionToken ,
233
- it ,
234
- 'returns inclusions after running replaceById() operation' ,
235
- async ( ) => {
236
- // this shows replaceById() works well with func ensurePersistable and ObjectId
237
- // the test skips for Cloudant as it needs the _rev property for replacement.
238
- // see replace-by-id.suite.ts
239
- const thor = await customerRepo . create ( { name : 'Thor' } ) ;
240
-
241
- const thorOrder = await orderRepo . create ( {
242
- customerId : thor . id ,
243
- description : 'Pizza' ,
244
- } ) ;
245
-
246
- const pizza = await orderRepo . findById ( thorOrder . id . toString ( ) ) ;
247
- const reheatedPizza = { ...pizza } ;
248
- reheatedPizza . description = 'Reheated pizza' ;
249
-
250
- await orderRepo . replaceById ( thorOrder . id , reheatedPizza ) ;
251
- const odinPizza = await orderRepo . findById ( thorOrder . id ) ;
252
-
253
- const result = await customerRepo . find ( {
254
- include : [ { relation : 'orders' } ] ,
255
- } ) ;
256
- const expected = [
257
- {
258
- ...thor ,
259
- parentId : features . emptyValue ,
260
- orders : [
261
- {
262
- ...odinPizza ,
263
- isShipped : features . emptyValue ,
264
- // eslint-disable-next-line @typescript-eslint/camelcase
265
- shipment_id : features . emptyValue ,
266
- } ,
267
- ] ,
268
- } ,
269
- ] ;
270
- expect ( toJSON ( result ) ) . to . deepEqual ( toJSON ( expected ) ) ;
271
- } ,
272
- ) ;
259
+ } ,
260
+ ] ;
261
+ expect ( toJSON ( result ) ) . to . deepEqual ( toJSON ( expected ) ) ;
262
+ } ) ;
273
263
274
264
it ( 'throws when navigational properties are present when updating model instance with save()' , async ( ) => {
275
265
// save() calls replaceById so the result will be the same for replaceById
0 commit comments