Skip to content

Commit

Permalink
add:test & SilkscreenPath
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijitxy committed Sep 8, 2024
1 parent 263ac09 commit 03e8212
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/register-catalogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import { SilkscreenPath } from "./components/primitive-components/SilkscreenPath
// register a component, as long as it's exported from lib/components
// it'll automatically be registered!
extendCatalogue(Components)
extendCatalogue({
...Components,
SilkscreenPath,
})


// Aliases (only when class name is different than the name of the component)
extendCatalogue({
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions tests/components/primitive-components/silkscreenpath.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { test, expect } from "bun:test"
import { getTestFixture } from "tests/fixtures/get-test-fixture"

test("SilkscreenPath rendering", () => {
const { project } = getTestFixture()

project.add(
<board width="10mm" height="10mm">
<silkscreenpath
route={[
{ x: "0mm", y: "0mm" },
{ x: "5mm", y: "5mm" },
{ x: "10mm", y: "0mm" }
]}
strokeWidth="0.2mm"
layer="top"
/>
</board>
)

project.render()

const silkscreenPaths = project.db.pcb_silkscreen_path.list()

console.log(JSON.stringify(silkscreenPaths[0], null, 2));

expect(silkscreenPaths.length).toBe(1)
expect(silkscreenPaths[0].layer).toBe("top")
expect(silkscreenPaths[0].stroke_width).toBe(0.2)

expect(silkscreenPaths[0].route).toEqual([
{ x: 0, y: 0 },
{ x: 5, y: 5 },
{ x: 10, y: 0 }
])

expect(silkscreenPaths[0].pcb_silkscreen_path_id).toBeTruthy()

Bun.write("silkscreenpath_test.json", JSON.stringify(silkscreenPaths, null, 2))
expect(project).toMatchPcbSnapshot(import.meta.path)
})

0 comments on commit 03e8212

Please sign in to comment.