Skip to content

Commit

Permalink
test(api): Add test: Should return the geometries of the countries fi…
Browse files Browse the repository at this point in the history
…ltered by partialProjectName
  • Loading branch information
alepefe committed Dec 10, 2024
1 parent 79e7891 commit 5ae3fd0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions api/test/integration/project-map/project-map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
);
});
});

0 comments on commit 5ae3fd0

Please sign in to comment.