Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusDec committed Mar 3, 2022
1 parent c302526 commit 02978ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 10 additions & 3 deletions src/controllers/units.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,16 @@ export const findOne = async (req, res) => {
await assertDataLayerAvailable();
res.json(
await Unit.findByPk(req.query.warehouseUnitId, {
include: Unit.getAssociatedModels().map(
(association) => association.model,
),
include: Unit.getAssociatedModels().map((association) => {
if (association.pluralize) {
return {
model: association.model,
as: association.model.name + 's',
};
}

return association.model;
}),
}),
);
} catch (error) {
Expand Down
8 changes: 1 addition & 7 deletions tests/integration/unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe.only('Unit Resource Integration Tests', function () {
const splitRecord2 = stagingRecord.diff.change[1];

// They should be getting their own ids
expect(splitRecord1.warehouseUnitId).to.not.equal(warehouseUnitIdToSplit);
expect(splitRecord1.warehouseUnitId).to.equal(warehouseUnitIdToSplit);
expect(splitRecord2.warehouseUnitId).to.not.equal(warehouseUnitIdToSplit);

// The first unitOwner is was reassigned,
Expand Down Expand Up @@ -348,12 +348,6 @@ describe.only('Unit Resource Integration Tests', function () {
]),
);

// make sure the original record was deleted
const warehouse3Res = await supertest(app)
.get(`/v1/units`)
.query({ warehouseUnitId: warehouseUnitIdToSplit });
expect(warehouse3Res.body).to.equal(null);

// Make sure the staging table is cleaned up
const stagingRes3 = await supertest(app).get('/v1/staging');

Expand Down

0 comments on commit 02978ad

Please sign in to comment.