Fix mocking

Signed-off-by: sblausten <sam@roadie.io>
This commit is contained in:
sblausten
2022-06-30 16:43:09 +02:00
parent 5dedcb541e
commit 8915b74167
2 changed files with 7 additions and 5 deletions
@@ -27,9 +27,11 @@ import { Knex } from 'knex';
jest.mock('./fact/FactRetrieverRegistry');
jest.mock('./fact/FactRetrieverEngine', () => ({
create: jest.fn().mockResolvedValue({
schedule: jest.fn(),
}),
FactRetrieverEngine: {
create: jest.fn().mockResolvedValue({
schedule: jest.fn(),
}),
},
}));
describe('buildTechInsightsContext', () => {
@@ -68,7 +70,6 @@ describe('buildTechInsightsContext', () => {
discovery: discoveryMock,
tokenManager: ServerTokenManager.noop(),
});
expect(DefaultFactRetrieverRegistry).toHaveBeenCalledTimes(1);
});
@@ -85,7 +86,6 @@ describe('buildTechInsightsContext', () => {
discovery: discoveryMock,
tokenManager: ServerTokenManager.noop(),
});
expect(DefaultFactRetrieverRegistry).not.toHaveBeenCalled();
});
});
@@ -120,6 +120,7 @@ export const buildTechInsightsContext = async <
scheduler,
tokenManager,
} = options;
logger.info('HERE1');
const buildFactRetrieverRegistry = (): FactRetrieverRegistry => {
if (!options.factRetrieverRegistry) {
@@ -139,6 +140,7 @@ export const buildTechInsightsContext = async <
await database.getClient(),
{ logger },
);
logger.info('HERE2');
const factRetrieverEngine = await FactRetrieverEngine.create({
scheduler,