Skip to content

add unit test coverage for parseLogicalOperatorPortID #6257

Description

@aglinxinyuan

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

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions