31 lines
936 B
TypeScript
31 lines
936 B
TypeScript
import assert from "node:assert/strict";
|
|
import { describe, it } from "node:test";
|
|
import { CircuitNumberingService } from "../src/domain/services/circuit-numbering.service.js";
|
|
|
|
describe("circuit numbering service", () => {
|
|
it("uses highest numeric suffix + 1 and does not fill gaps", async () => {
|
|
const service = new CircuitNumberingService({
|
|
sectionRepository: {
|
|
async findById() {
|
|
return { id: "s1", prefix: "-2F" } as never;
|
|
},
|
|
},
|
|
circuitRepository: {
|
|
async listBySection() {
|
|
return [
|
|
{ equipmentIdentifier: "-2F1" },
|
|
{ equipmentIdentifier: "-2F2" },
|
|
{ equipmentIdentifier: "-2F5" },
|
|
{ equipmentIdentifier: "-2FX" },
|
|
{ equipmentIdentifier: "-1F9" },
|
|
] as never[];
|
|
},
|
|
},
|
|
});
|
|
|
|
const next = await service.getNextIdentifier("s1");
|
|
assert.equal(next, "-2F6");
|
|
});
|
|
});
|
|
|