Add SchematicSheet props and introduce schSheetName common prop#705
Open
seveibar wants to merge 1 commit into
Open
Add SchematicSheet props and introduce schSheetName common prop#705seveibar wants to merge 1 commit into
schSheetName common prop#705seveibar wants to merge 1 commit into
Conversation
Comment on lines
+1
to
+34
| import { expect, test } from "bun:test" | ||
| import { | ||
| schematicSheetProps, | ||
| type SchematicSheetProps, | ||
| } from "lib/components/schematic-sheet" | ||
| import { expectTypeOf } from "expect-type" | ||
|
|
||
| test("should parse schematic sheet with name, displayName, and children", () => { | ||
| const raw: SchematicSheetProps = { | ||
| name: "main", | ||
| displayName: "Main Sheet", | ||
| children: [{ type: "resistor", props: { name: "R1" } }], | ||
| } | ||
|
|
||
| expectTypeOf(raw).toMatchTypeOf<SchematicSheetProps>() | ||
| const parsed = schematicSheetProps.parse(raw) | ||
| expect(parsed.name).toBe("main") | ||
| expect(parsed.displayName).toBe("Main Sheet") | ||
| expect(parsed.children).toEqual([{ type: "resistor", props: { name: "R1" } }]) | ||
| }) | ||
|
|
||
| test("should parse schematic sheet without children", () => { | ||
| const raw: SchematicSheetProps = { | ||
| name: "power", | ||
| displayName: "Power Sheet", | ||
| } | ||
|
|
||
| const parsed = schematicSheetProps.parse(raw) | ||
| expect(parsed.children).toBeUndefined() | ||
| }) | ||
|
|
||
| test("should fail without displayName", () => { | ||
| expect(() => schematicSheetProps.parse({ name: "main" })).toThrow() | ||
| }) |
Contributor
There was a problem hiding this comment.
This file contains three test(...) calls, but the rule states that a *.test.ts file may have AT MOST one test(...). Please split this into multiple numbered files, e.g. schematic-sheet1.test.ts, schematic-sheet2.test.ts, and schematic-sheet3.test.ts, each containing exactly one test.
Spotted by Graphite (based on custom rule: Custom rule)
Is this helpful? React 👍 or 👎 to let us know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
schSheetNamecomponent prop to let components opt into being drawn on a specific sheet analogous toschSectionName.Description
SchematicSheetPropsandschematicSheetPropsschema inlib/components/schematic-sheet.tswith requirednameanddisplayNameand optionalchildren.schSheetName?: stringtoCommonComponentPropsand thecommonComponentPropsZod schema inlib/common/layout.tswith a descriptive comment matching theschSectionNamepattern.lib/index.tsand updatescripts/generate-readme-docs.tsso generated docs include the new sheet prop andschSheetNamedocumentation.tests/schematic-sheet.test.tsthat validate parsing with and withoutchildrenand thatdisplayNameis required.Testing
bun scripts/generate-component-types.ts,bun scripts/generate-manual-edits-docs.ts,bun scripts/generate-readme-docs.ts, andbun scripts/generate-props-overview.tsand updated docs successfully.bun run formatand ensured formatting completed without issues.bun test tests/schematic-sheet.test.tswhich reported3 pass, 0 fail.bunx tsc --noEmitwhich completed without errors.Codex Task