From 8fbcda239c0ae9c4484e9079b6d47c83cb212b48 Mon Sep 17 00:00:00 2001 From: andrea rota Date: Fri, 6 Dec 2024 13:35:31 +0000 Subject: [PATCH] update tests to match current expected values --- .../compute-area.service.spec.ts | 13 +++++-- .../upload-feature/upload-feature.fixtures.ts | 38 +++++++++---------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/api/apps/api/src/modules/scenarios-features/compute-area.service.spec.ts b/api/apps/api/src/modules/scenarios-features/compute-area.service.spec.ts index b65b8cc474..a2f4ffd1ac 100644 --- a/api/apps/api/src/modules/scenarios-features/compute-area.service.spec.ts +++ b/api/apps/api/src/modules/scenarios-features/compute-area.service.spec.ts @@ -85,7 +85,8 @@ describe(ComputeArea, () => { const getFixtures = async () => { const computeMarxanAmountPerPlanningUnitMock = jest.fn(); const findProjectMock = jest.fn(); - const findGeoFeatureMock = jest.fn(); + const findOneOrFailGeoFeatureMock = jest.fn(); + const findOneGeoFeatureMock = jest.fn(); const saveAmountRangeForFeaturesMock = jest.fn(); const sandbox = await Test.createTestingModule({ imports: [], @@ -96,7 +97,10 @@ const getFixtures = async () => { }, { provide: getRepositoryToken(GeoFeature), - useValue: { findOneOrFail: findGeoFeatureMock }, + useValue: { + findOneOrFail: findOneOrFailGeoFeatureMock, + findOne: findOneGeoFeatureMock, + }, }, { provide: GeoFeaturesService, @@ -189,11 +193,14 @@ const getFixtures = async () => { ]; }, GivenMinMaxAmount: (featureId: string, min?: number, max?: number) => { - findGeoFeatureMock.mockResolvedValueOnce({ + findOneOrFailGeoFeatureMock.mockResolvedValueOnce({ id: featureId, amountMin: min, amountMax: max, }); + findOneGeoFeatureMock.mockResolvedValueOnce({ + featureDataStableIds: [], + }); }, WhenComputing: (projectId: string, scenarioId: string, featureId: string) => sut.computeAreaPerPlanningUnitOfFeature(projectId, scenarioId, featureId), diff --git a/api/apps/api/test/upload-feature/upload-feature.fixtures.ts b/api/apps/api/test/upload-feature/upload-feature.fixtures.ts index 43f63ab401..be4e14cd6e 100644 --- a/api/apps/api/test/upload-feature/upload-feature.fixtures.ts +++ b/api/apps/api/test/upload-feature/upload-feature.fixtures.ts @@ -389,25 +389,25 @@ export const getFixtures = async () => { featureClassName: name, }, }); - expect(features).toEqual([ - { - id: expect.any(String), - featureClassName: name, - featureDataStableIds: null, - description, - alias: null, - amountMax: 5296399725.20094, - amountMin: 820348505.9774874, - propertyName: null, - intersection: null, - creationStatus: JobStatus.created, - projectId, - isCustom: true, - isLegacy: false, - fromGeoprocessingOps: null, - geoprocessingOpsHash: null, - }, - ]); + const expectedFeature = new GeoFeature(); + Object.assign(expectedFeature, { + id: expect.any(String), + featureClassName: name, + featureDataStableIds: [expect.any(String)], + description, + alias: null, + amountMax: 5296399725.20094, + amountMin: 820348505.9774874, + propertyName: null, + intersection: null, + creationStatus: JobStatus.created, + projectId, + isCustom: true, + isLegacy: false, + fromGeoprocessingOps: null, + geoprocessingOpsHash: null, + }); + expect(features).toEqual([expectedFeature]); expect( await geoFeatureDataRepo.find({ where: {