Add optional room areas
This commit is contained in:
parent
a6500e2b26
commit
dce31ee143
26 changed files with 3669 additions and 78 deletions
|
|
@ -21,6 +21,7 @@ import {
|
|||
normalizeBuildingSelection,
|
||||
normalizeFloorSelection,
|
||||
showsRoomsWithoutFloorEntry,
|
||||
summarizeRoomAreas,
|
||||
} from "../src/frontend/utils/building-structure.js";
|
||||
|
||||
function building(id: string, name: string, sortOrder: number): BuildingDto {
|
||||
|
|
@ -36,13 +37,19 @@ function floor(
|
|||
return { id, projectId: "project-1", name, sortOrder, buildingId };
|
||||
}
|
||||
|
||||
function room(id: string, floorId: string | null, roomNumber = id): RoomDto {
|
||||
function room(
|
||||
id: string,
|
||||
floorId: string | null,
|
||||
roomNumber = id,
|
||||
areaM2: number | null = null
|
||||
): RoomDto {
|
||||
return {
|
||||
id,
|
||||
projectId: "project-1",
|
||||
floorId,
|
||||
roomNumber,
|
||||
roomName: `Raum ${roomNumber}`,
|
||||
areaM2,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -263,6 +270,43 @@ describe("building structure view", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("sums known areas and counts missing areas per floor and building", () => {
|
||||
const areaRooms = [
|
||||
room("a", "f-a-eg", "a", 20.25),
|
||||
room("b", "f-a-eg"),
|
||||
room("c", "f-free", "c", 5.5),
|
||||
room("d", null, "d", 3),
|
||||
room("e", "f-deleted"),
|
||||
];
|
||||
const summaries = summarizeRoomAreas(areaRooms, floors, buildings);
|
||||
|
||||
assert.deepEqual(summaries.total, {
|
||||
areaM2: 28.75,
|
||||
roomCount: 5,
|
||||
missingAreaCount: 2,
|
||||
});
|
||||
assert.deepEqual(summaries.byFloor.get("f-a-eg"), {
|
||||
areaM2: 20.25,
|
||||
roomCount: 2,
|
||||
missingAreaCount: 1,
|
||||
});
|
||||
assert.deepEqual(summaries.byFloor.get(null), {
|
||||
areaM2: 3,
|
||||
roomCount: 2,
|
||||
missingAreaCount: 1,
|
||||
});
|
||||
assert.deepEqual(summaries.byBuilding.get("b-a"), {
|
||||
areaM2: 20.25,
|
||||
roomCount: 2,
|
||||
missingAreaCount: 1,
|
||||
});
|
||||
assert.deepEqual(summaries.byBuilding.get(null), {
|
||||
areaM2: 8.5,
|
||||
roomCount: 3,
|
||||
missingAreaCount: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it("describes a room location with floor and building", () => {
|
||||
assert.equal(
|
||||
describeRoomLocation(room("r", "f-a-og"), floors, buildings),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue