Skip to content

Commit

Permalink
test: improve datafoncier housing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Falinor committed Nov 28, 2024
1 parent 25ef101 commit bb4a627
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion frontend/src/mocks/handlers/housing-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const housingHandlers: RequestHandler[] = [

// Add a housing
http.post<never, HousingPayloadDTO, HousingDTO>(
`${config.apiEndpoint}/api/housing/creation`,
`${config.apiEndpoint}/api/housing`,
async ({ request }) => {
const payload = await request.json();
const datafoncierHousing = data.datafoncierHousings.find(
Expand Down
2 changes: 1 addition & 1 deletion packages/models/src/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function genDatafoncierHousingDTO(
dloy48a: faker.number.int(99),
top48a: faker.string.alphanumeric(1),
dnatlc: faker.string.alphanumeric(1),
ccthp: faker.helpers.arrayElement(['L', 'V']),
ccthp: faker.helpers.arrayElement(OCCUPANCY_VALUES),
proba_rprs: faker.string.alphanumeric(7),
typeact: faker.string.alphanumeric(4),
loghvac: faker.string.alphanumeric(1),
Expand Down
5 changes: 5 additions & 0 deletions server/src/controllers/housingController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,16 @@ describe('Housing API', () => {
`${housingOwnersTable}.housing_id`
)
.where(`${housingTable}.local_id`, datafoncierHousing.idlocal);
expect(actualOwners.length).toBe(datafoncierOwners.length);
expect(actualOwners).toSatisfyAll<OwnerRecordDBO>((actualOwner) => {
return existingOwners.some((existingOwner) => {
return existingOwner.id === actualOwner.id;
});
});
const actualHousing = await Housing()
.where({ local_id: datafoncierHousing.idlocal })
.first();
expect(actualHousing).toBeDefined();
});

it('should assign its owners', async () => {
Expand Down
2 changes: 1 addition & 1 deletion server/src/test/testFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ export const genDatafoncierHousing = (
dloy48a: genNumber(2),
top48a: randomstring.generate(1),
dnatlc: randomstring.generate(1),
ccthp: oneOf(['L', 'V']),
ccthp: faker.helpers.arrayElement([...OCCUPANCY_VALUES, null]),
proba_rprs: randomstring.generate(7),
typeact: randomstring.generate(4),
loghvac: randomstring.generate(1),
Expand Down

0 comments on commit bb4a627

Please sign in to comment.