Files
leistungsbilanz-ts/tests/project-device-schema.test.ts
T

37 lines
1.0 KiB
TypeScript

import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { createProjectDeviceSchema } from "../src/shared/validation/project-device.schemas.js";
describe("project device circuit-first schema", () => {
it("accepts circuit device fields", () => {
const result = createProjectDeviceSchema.safeParse({
name: "E-Line Pro",
displayName: "Office lighting",
phaseType: "single_phase",
connectionKind: "fixed",
costGroup: "440",
category: "Lighting",
quantity: 6,
powerPerUnit: 0.04,
simultaneityFactor: 0.8,
cosPhi: 0.95,
remark: "DALI",
});
assert.equal(result.success, true);
});
it("requires the circuit-first power and phase fields", () => {
const result = createProjectDeviceSchema.safeParse({
name: "Legacy device",
displayName: "Legacy device",
quantity: 1,
installedPowerPerUnitKw: 0.1,
demandFactor: 1,
phaseCount: 1,
});
assert.equal(result.success, false);
});
});