diff --git a/src/api/scenarioData/scenarioData.service.spec.ts b/src/api/scenarioData/scenarioData.service.spec.ts index 3988db5..68c725b 100644 --- a/src/api/scenarioData/scenarioData.service.spec.ts +++ b/src/api/scenarioData/scenarioData.service.spec.ts @@ -267,12 +267,13 @@ describe('ScenarioDataService', () => { it('should return scenarios by filename', async () => { const goRulesJSONFilename = 'test.json'; const scenarioDataList: ScenarioData[] = [mockScenarioData]; + scenarioDataList[0].goRulesJSONFilename = goRulesJSONFilename; MockScenarioDataModel.find = jest.fn().mockReturnValue({ exec: jest.fn().mockResolvedValue(scenarioDataList) }); const result = await service.getScenariosByFilename(goRulesJSONFilename); expect(result).toEqual(scenarioDataList); - expect(MockScenarioDataModel.find).toHaveBeenCalledWith({ goRulesJSONFilename }); + expect(MockScenarioDataModel.find).toHaveBeenCalledWith({ goRulesJSONFilename: { $eq: goRulesJSONFilename } }); }); it('should throw an error if an error occurs while retrieving scenarios by filename', async () => { @@ -287,7 +288,7 @@ describe('ScenarioDataService', () => { await service.getScenariosByFilename(goRulesJSONFilename); }).rejects.toThrowError(`Error getting scenarios by filename: ${errorMessage}`); - expect(MockScenarioDataModel.find).toHaveBeenCalledWith({ goRulesJSONFilename }); + expect(MockScenarioDataModel.find).toHaveBeenCalledWith({ goRulesJSONFilename: { $eq: goRulesJSONFilename } }); }); }); describe('runDecisionsForScenarios', () => { diff --git a/src/api/scenarioData/scenarioData.service.ts b/src/api/scenarioData/scenarioData.service.ts index b2d27ed..5105949 100644 --- a/src/api/scenarioData/scenarioData.service.ts +++ b/src/api/scenarioData/scenarioData.service.ts @@ -86,7 +86,7 @@ export class ScenarioDataService { async getScenariosByFilename(goRulesJSONFilename: string): Promise { try { - return await this.scenarioDataModel.find({ goRulesJSONFilename: goRulesJSONFilename }).exec(); + return await this.scenarioDataModel.find({ goRulesJSONFilename: { $eq: goRulesJSONFilename } }).exec(); } catch (error) { throw new Error(`Error getting scenarios by filename: ${error.message}`); }