Task Summary
Add logical-operator-port-serde.spec.ts covering parseLogicalOperatorPortID, which parses a port-id string like "input-0" / "output-3" into { portNumber, portType }.
Background
frontend/src/app/common/util/logical-operator-port-serde.ts exports one pure parser and has no test.
export function parseLogicalOperatorPortID(
portId: string
): { portNumber: number; portType: "input" | "output" } | undefined {
const match = portId.match(/^(input|output)-(\d+)$/);
if (!match) return undefined;
return { portNumber: parseInt(match[2]), portType: match[1] as "input" | "output" };
}
Behavior to pin
| Input |
Result |
"input-0" |
{ portNumber: 0, portType: "input" } |
"output-12" |
{ portNumber: 12, portType: "output" } |
"foo-1", "input-", "input-1-2", "" |
undefined |
Follow size-formatter.util.spec.ts in common/util/ as the style template (plain describe/it/expect, run with ng test).
Scope
- New spec:
frontend/src/app/common/util/logical-operator-port-serde.spec.ts.
- No production-code changes.
Task Type
Task Summary
Add
logical-operator-port-serde.spec.tscoveringparseLogicalOperatorPortID, which parses a port-id string like"input-0"/"output-3"into{ portNumber, portType }.Background
frontend/src/app/common/util/logical-operator-port-serde.tsexports one pure parser and has no test.Behavior to pin
"input-0"{ portNumber: 0, portType: "input" }"output-12"{ portNumber: 12, portType: "output" }"foo-1","input-","input-1-2",""undefinedFollow
size-formatter.util.spec.tsincommon/util/as the style template (plaindescribe/it/expect, run withng test).Scope
frontend/src/app/common/util/logical-operator-port-serde.spec.ts.Task Type