-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea69454
commit 8bfbc22
Showing
4 changed files
with
235 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
diff a/tests/integration/unit.spec.js b/tests/integration/unit.spec.js (rejected hunks) | ||
@@ -123,79 +133,64 @@ describe('Create Unit Integration', () => { | ||
// The node simulator runs on an async process, we are importing | ||
// the WAIT_TIME constant from the simulator, padding it and waiting for the | ||
// appropriate amount of time for the simulator to finish its operations | ||
- await new Promise((resolve, reject) => { | ||
- setTimeout(async () => { | ||
- try { | ||
- const warehouseRes = await supertest(app) | ||
- .get(`/v1/units`) | ||
- .query({ warehouseUnitId: splitRecord1.warehouseUnitId }); | ||
- | ||
- const newRecord1 = warehouseRes.body; | ||
- | ||
- expect(newRecord1.warehouseUnitId).to.equal( | ||
- splitRecord1.warehouseUnitId, | ||
- ); | ||
- expect(newRecord1.orgUid).to.equal(splitRecord1.orgUid); | ||
- expect(newRecord1.unitOwnerOrgUid).to.equal( | ||
- splitRecord1.unitOwnerOrgUid, | ||
- ); | ||
- expect(newRecord1.serialNumberBlock).to.equal( | ||
- splitRecord1.serialNumberBlock, | ||
- ); | ||
- expect(newRecord1.countryJuridictionOfOwner).to.equal( | ||
- splitRecord1.countryJuridictionOfOwner, | ||
- ); | ||
- expect(newRecord1.inCountryJuridictionOfOwner).to.equal( | ||
- splitRecord1.inCountryJuridictionOfOwner, | ||
- ); | ||
- expect(newRecord1.tokenIssuanceHash).to.equal( | ||
- splitRecord1.tokenIssuanceHash, | ||
- ); | ||
- | ||
- const warehouse2Res = await supertest(app) | ||
- .get(`/v1/units`) | ||
- .query({ warehouseUnitId: splitRecord2.warehouseUnitId }); | ||
- | ||
- const newRecord2 = warehouse2Res.body; | ||
- | ||
- expect(newRecord2.warehouseUnitId).to.equal( | ||
- splitRecord2.warehouseUnitId, | ||
- ); | ||
- expect(newRecord2.orgUid).to.equal(splitRecord2.orgUid); | ||
- expect(newRecord2.unitOwnerOrgUid).to.equal( | ||
- splitRecord2.unitOwnerOrgUid, | ||
- ); | ||
- expect(newRecord1.serialNumberBlock).to.equal( | ||
- splitRecord1.serialNumberBlock, | ||
- ); | ||
- expect(newRecord2.countryJuridictionOfOwner).to.equal( | ||
- splitRecord2.countryJuridictionOfOwner, | ||
- ); | ||
- expect(newRecord2.inCountryJuridictionOfOwner).to.equal( | ||
- splitRecord2.inCountryJuridictionOfOwner, | ||
- ); | ||
- expect(newRecord2.tokenIssuanceHash).to.equal( | ||
- splitRecord2.tokenIssuanceHash, | ||
- ); | ||
- | ||
- // 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'); | ||
- | ||
- // There should be no staging records left | ||
- expect(stagingRes3.body.length).to.equal(0); | ||
- | ||
- resolve(); | ||
- } catch (err) { | ||
- reject(err); | ||
- } | ||
- }, WAIT_TIME * 3); | ||
- }); | ||
+ clock.tick(WAIT_TIME * 4); | ||
+ | ||
+ const warehouseRes = await supertest(app) | ||
+ .get(`/v1/units`) | ||
+ .query({ warehouseUnitId: splitRecord1.warehouseUnitId }); | ||
+ | ||
+ const newRecord1 = warehouseRes.body; | ||
+ console.log(newRecord1, splitRecord1.warehouseUnitId); | ||
+ | ||
+ expect(newRecord1.warehouseUnitId).to.equal(splitRecord1.warehouseUnitId); | ||
+ expect(newRecord1.orgUid).to.equal(splitRecord1.orgUid); | ||
+ expect(newRecord1.unitOwnerOrgUid).to.equal(splitRecord1.unitOwnerOrgUid); | ||
+ expect(newRecord1.serialNumberBlock).to.equal( | ||
+ splitRecord1.serialNumberBlock, | ||
+ ); | ||
+ expect(newRecord1.countryJuridictionOfOwner).to.equal( | ||
+ splitRecord1.countryJuridictionOfOwner, | ||
+ ); | ||
+ expect(newRecord1.inCountryJuridictionOfOwner).to.equal( | ||
+ splitRecord1.inCountryJuridictionOfOwner, | ||
+ ); | ||
+ expect(newRecord1.tokenIssuanceHash).to.equal( | ||
+ splitRecord1.tokenIssuanceHash, | ||
+ ); | ||
+ | ||
+ const warehouse2Res = await supertest(app) | ||
+ .get(`/v1/units`) | ||
+ .query({ warehouseUnitId: splitRecord2.warehouseUnitId }); | ||
+ | ||
+ const newRecord2 = warehouse2Res.body; | ||
+ | ||
+ expect(newRecord2.warehouseUnitId).to.equal(splitRecord2.warehouseUnitId); | ||
+ expect(newRecord2.orgUid).to.equal(splitRecord2.orgUid); | ||
+ expect(newRecord2.unitOwnerOrgUid).to.equal(splitRecord2.unitOwnerOrgUid); | ||
+ expect(newRecord1.serialNumberBlock).to.equal( | ||
+ splitRecord1.serialNumberBlock, | ||
+ ); | ||
+ expect(newRecord2.countryJuridictionOfOwner).to.equal( | ||
+ splitRecord2.countryJuridictionOfOwner, | ||
+ ); | ||
+ expect(newRecord2.inCountryJuridictionOfOwner).to.equal( | ||
+ splitRecord2.inCountryJuridictionOfOwner, | ||
+ ); | ||
+ expect(newRecord2.tokenIssuanceHash).to.equal( | ||
+ splitRecord2.tokenIssuanceHash, | ||
+ ); | ||
+ | ||
+ // 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'); | ||
+ | ||
+ // There should be no staging records left | ||
+ expect(stagingRes3.body.length).to.equal(0); | ||
}); | ||
|
||
it('creates a new unit end-to-end', async () => { | ||
@@ -264,42 +259,30 @@ describe('Create Unit Integration', () => { | ||
// The node simulator runs on an async process, we are importing | ||
// the WAIT_TIME constant from the simulator, padding it and waiting for the | ||
// appropriate amount of time for the simulator to finish its operations | ||
- await new Promise((resolve, reject) => { | ||
- setTimeout(async () => { | ||
- try { | ||
- // Make sure the staging table is cleaned up | ||
- const stagingRes3 = await supertest(app).get('/v1/staging'); | ||
- | ||
- // There should be no staging records left | ||
- expect(stagingRes3.body.length).to.equal(0); | ||
- | ||
- const warehouseRes = await supertest(app) | ||
- .get(`/v1/units`) | ||
- .query({ warehouseUnitId }); | ||
- | ||
- const newRecord = warehouseRes.body; | ||
- | ||
- expect(newRecord.warehouseUnitId).to.equal(warehouseUnitId); | ||
- expect(newRecord.orgUid).to.equal(orgUid); | ||
- expect(newRecord.unitOwnerOrgUid).to.equal(orgUid); | ||
- expect(newRecord.serialNumberBlock).to.equal( | ||
- payload.serialNumberBlock, | ||
- ); | ||
- expect(newRecord.countryJuridictionOfOwner).to.equal( | ||
- payload.countryJuridictionOfOwner, | ||
- ); | ||
- expect(newRecord.inCountryJuridictionOfOwner).to.equal( | ||
- payload.inCountryJuridictionOfOwner, | ||
- ); | ||
- expect(newRecord.tokenIssuanceHash).to.equal( | ||
- payload.tokenIssuanceHash, | ||
- ); | ||
- | ||
- resolve(); | ||
- } catch (err) { | ||
- reject(err); | ||
- } | ||
- }, WAIT_TIME * 2); | ||
- }); | ||
+ clock.tick(WAIT_TIME * 2); | ||
+ | ||
+ // Make sure the staging table is cleaned up | ||
+ const stagingRes3 = await supertest(app).get('/v1/staging'); | ||
+ | ||
+ // There should be no staging records left | ||
+ expect(stagingRes3.body.length).to.equal(0); | ||
+ | ||
+ const warehouseRes = await supertest(app) | ||
+ .get(`/v1/units`) | ||
+ .query({ warehouseUnitId }); | ||
+ | ||
+ const newRecord = warehouseRes.body; | ||
+ | ||
+ expect(newRecord.warehouseUnitId).to.equal(warehouseUnitId); | ||
+ expect(newRecord.orgUid).to.equal(orgUid); | ||
+ expect(newRecord.unitOwnerOrgUid).to.equal(orgUid); | ||
+ expect(newRecord.serialNumberBlock).to.equal(payload.serialNumberBlock); | ||
+ expect(newRecord.countryJuridictionOfOwner).to.equal( | ||
+ payload.countryJuridictionOfOwner, | ||
+ ); | ||
+ expect(newRecord.inCountryJuridictionOfOwner).to.equal( | ||
+ payload.inCountryJuridictionOfOwner, | ||
+ ); | ||
+ expect(newRecord.tokenIssuanceHash).to.equal(payload.tokenIssuanceHash); | ||
}); | ||
}); |