Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/components/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ const baseTraceProps = z.object({
schStroke: z.string().optional(),
highlightColor: z.string().optional(),
maxLength: distance.optional(),
maxViaCount: z
.number()
.int()
.nonnegative()
.optional()
.describe("Maximum number of vias allowed in the PCB trace route"),
connectsTo: z.string().or(z.array(z.string())).optional(),
})

Expand Down
14 changes: 14 additions & 0 deletions tests/trace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ test("supports pcbStraightLine flag", () => {
expect(parsed.pcbStraightLine).toBe(true)
})

test("supports limiting the maximum number of PCB vias", () => {
const raw: TraceProps = {
from: "A",
to: "B",
maxViaCount: 0,
}

const parsed = traceProps.parse(raw)

expect(parsed.maxViaCount).toBe(0)
expect(() => traceProps.parse({ ...raw, maxViaCount: -1 })).toThrow()
expect(() => traceProps.parse({ ...raw, maxViaCount: 1.5 })).toThrow()
})
Comment on lines +92 to +104

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The style guide states that a *.test.ts file may have AT MOST one test(...) call. This new test block ("supports limiting the maximum number of PCB vias") is being added to trace.test.ts, which already contains at least one other test(...) (e.g., the "accepts start/end aliases for trace endpoints" test at line 92/106, and others visible earlier in the file). Once a file has more than one test, the tests must be split into multiple numbered files — for example, trace1.test.ts, trace2.test.ts, etc. Please move this new test into its own numbered file (e.g., trace2.test.ts or an appropriate number) to comply with the one-test-per-file rule.

Spotted by Graphite (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.


test("accepts start/end aliases for trace endpoints", () => {
const raw: TraceProps = {
start: "A",
Expand Down
Loading