From 5ae3fd0b742bc782335bb6fcc4a6585007bfe6c6 Mon Sep 17 00:00:00 2001 From: Alejandro Peralta Date: Tue, 10 Dec 2024 10:47:07 +0100 Subject: [PATCH] test(api): Add test: Should return the geometries of the countries filtered by partialProjectName --- .../project-map/project-map.spec.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/api/test/integration/project-map/project-map.spec.ts b/api/test/integration/project-map/project-map.spec.ts index eaba2526..576233be 100644 --- a/api/test/integration/project-map/project-map.spec.ts +++ b/api/test/integration/project-map/project-map.spec.ts @@ -8,6 +8,7 @@ import { import { Country } from '@shared/entities/country.entity'; import { projectsContract } from '@shared/contracts/projects.contract'; import { ECOSYSTEM } from '@shared/entities/ecosystem.enum'; +import { partial } from 'lodash'; describe('Project Map', () => { let testManager: TestManager; @@ -292,4 +293,39 @@ describe('Project Map', () => { countries[1].name, ); }); + + test('Should return the geometries of the countries filtered by partialProjectName', async () => { + const countries = await testManager + .getDataSource() + .getRepository(Country) + .find({ take: 1 }); + + await Promise.all([ + testManager.mocks().createProject({ + projectName: 'MyProjectName', + projectSizeFilter: PROJECT_SIZE_FILTER.MEDIUM, + priceType: PROJECT_PRICE_TYPE.MARKET_PRICE, + countryCode: countries[0].code, + }), + testManager.mocks().createProject({ + projectName: 'ShouldNotBeReturned', + projectSizeFilter: PROJECT_SIZE_FILTER.MEDIUM, + priceType: PROJECT_PRICE_TYPE.MARKET_PRICE, + countryCode: countries[0].code, + }), + ]); + + const response = await testManager + .request() + .get(projectsContract.getProjectsMap.path) + .query({ + partialProjectName: 'myproject', + }); + + expect(response.status).toBe(HttpStatus.OK); + expect(response.body.features).toHaveLength(1); + expect(response.body.features[0].properties.country).toBe( + countries[0].name, + ); + }); });