Wrap test in waitForExpect

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2021-05-03 14:13:25 +02:00
parent 0bd4dfa9d2
commit 852b6bec95
3 changed files with 26 additions and 10 deletions
+2 -1
View File
@@ -73,7 +73,8 @@
"@types/yup": "^0.29.8",
"msw": "^0.21.2",
"sqlite3": "^5.0.0",
"supertest": "^6.1.3"
"supertest": "^6.1.3",
"wait-for-expect": "^3.0.2"
},
"files": [
"dist",
@@ -20,6 +20,7 @@ import { DefaultProcessingDatabase } from './database/DefaultProcessingDatabase'
import { DefaultCatalogProcessingEngine } from './DefaultCatalogProcessingEngine';
import { Stitcher } from './Stitcher';
import { CatalogProcessingOrchestrator } from './types';
import waitForExpect from 'wait-for-expect';
describe('DefaultCatalogProcessingEngine', () => {
const db = ({
@@ -83,13 +84,17 @@ describe('DefaultCatalogProcessingEngine', () => {
});
await engine.start();
await new Promise<void>(resolve => setTimeout(resolve, 1));
expect(orchestrator.process).toBeCalledTimes(1);
expect(orchestrator.process).toBeCalledWith({
entity: { apiVersion: '1', kind: 'Location', metadata: { name: 'test' } },
state: expect.anything(),
await waitForExpect(() => {
expect(orchestrator.process).toBeCalledTimes(1);
expect(orchestrator.process).toBeCalledWith({
entity: {
apiVersion: '1',
kind: 'Location',
metadata: { name: 'test' },
},
state: expect.anything(),
});
});
await engine.stop();
});
});