Skip to content
Draft
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
2 changes: 1 addition & 1 deletion lib/convert-easyeda-json-to-tscircuit-soup-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export const convertEasyEdaJsonToCircuitJson = (
source_component_id: "source_component_1",
pcb_component_id: "pcb_component_1",
position: { x: 0, y: 0, z: 0 },
rotation: { x: rx, y: ry, z: rz },
rotation: { x: rx, y: ry, z: (rz + 180) % 360 },
model_obj_url: objFileUrl,
} as Soup.CadComponentInput),
)
Expand Down
13 changes: 11 additions & 2 deletions tests/convert-to-ts/C165948-to-ts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { convertBetterEasyToTsx } from "lib/websafe/convert-to-typescript-compon
import { EasyEdaJsonSchema } from "lib/schemas/easy-eda-json-schema"
import { convertEasyEdaJsonToCircuitJson } from "lib/convert-easyeda-json-to-tscircuit-soup-json"
import { convertCircuitJsonToPcbSvg } from "circuit-to-svg"
import { runTscircuitCode } from "tscircuit"

it("should convert C165948 into typescript file", async () => {
const betterEasy = EasyEdaJsonSchema.parse(chipRawEasy)
Expand All @@ -16,11 +17,19 @@ it("should convert C165948 into typescript file", async () => {
expect(result).toContain('shape="pill"')
})

it("C165948 should generate Circuit Json without errors", () => {
it("C165948 should generate Circuit Json without errors", async () => {
const betterEasy = EasyEdaJsonSchema.parse(chipRawEasy)
const circuitJson = convertEasyEdaJsonToCircuitJson(betterEasy)
const circuitJson = convertEasyEdaJsonToCircuitJson(betterEasy, {
useModelCdn: true,
})

const tsxResult = await convertBetterEasyToTsx({
betterEasy,
})
const circuitJson2 = await runTscircuitCode(tsxResult)

expect(convertCircuitJsonToPcbSvg(circuitJson)).toMatchSvgSnapshot(
import.meta.path,
)
await expect(circuitJson2).toMatch3dSnapshot(import.meta.path)
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/convert-to-ts/__snapshots__/C9900017879-to-ts.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/fixtures/3d-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ async function toMatch3dSnapshot(
const svg = await convertCircuitJsonToSimple3dSvg(
circuitJson.concat({
type: "pcb_board",
width: 50,
height: 50,
width: 25,
height: 25,
center: { x: 0, y: 0 },
pcb_board_id: "board1",
thickness: 1.6,
Expand Down
Loading