Skip to content

Commit

Permalink
fix: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jannyHou authored and Agnes Lin committed Dec 3, 2019
1 parent 8b88b96 commit a55152e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,17 @@ export function hasManyInclusionResolverAcceptance(
});

const pizza = await orderRepo.findById(thorOrder.id.toString());
const reheatedPizza = {...pizza};
reheatedPizza.description = 'Reheated pizza';
pizza.description = 'Reheated pizza';
const reheatedPizza = toJSON(pizza);

await orderRepo.replaceById(thorOrder.id, reheatedPizza);
// coerce the id for mongodb connector to pass the id equality check
// in juggler's replaceById function
const coercedId =
typeof thorOrder.id === 'number'
? thorOrder.id
: thorOrder.id.toString();

await orderRepo.replaceById(coercedId, reheatedPizza);
const odinPizza = await orderRepo.findById(thorOrder.id);

const result = await customerRepo.find({
Expand Down
3 changes: 0 additions & 3 deletions packages/repository-tests/src/crud/relations/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ export function givenBoundCrudRepositories(
Order.definition.properties.id.type = features.idType;
Address.definition.properties.id.type = features.idType;
Customer.definition.properties.id.type = features.idType;
Customer.definition.properties.id.mongodb = {
dataType: 'ObjectID',
};
Shipment.definition.properties.id.type = features.idType;
// when running the test suite on MongoDB, we don't really need to setup
// this config for mongo connector to pass the test.
Expand Down
13 changes: 8 additions & 5 deletions packages/repository-tests/src/crud/replace-by-id.suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Entity, model, property} from '@loopback/repository';
import {AnyObject, EntityCrudRepository} from '@loopback/repository';
import {
AnyObject,
Entity,
EntityCrudRepository,
model,
property,
} from '@loopback/repository';
import {expect, toJSON} from '@loopback/testlab';
import {MixedIdType} from '../helpers.repository-tests';
import {
deleteAllModelsInDefaultDataSource,
MixedIdType,
withCrudCtx,
} from '../helpers.repository-tests';
import {
Expand Down Expand Up @@ -72,7 +77,6 @@ export function createSuiteForReplaceById(
// This important! Not all databases allow `patchById` to set
// properties to "undefined", `replaceById` must always work.
created.description = undefined;

await repo.replaceById(created.id, created);

const found = await repo.findById(created.id);
Expand Down Expand Up @@ -112,7 +116,6 @@ export function createSuiteForReplaceById(
// This important! Not all databases allow `patchById` to set
// properties to "undefined", `replaceById` must always work.
created.description = undefined;

await repo.replaceById(created.id, created);

const found = await repo.findById(created.id);
Expand Down

0 comments on commit a55152e

Please sign in to comment.