import { createCircuitWebWorker } from "lib"
import { expect, test } from "bun:test"
test("virtual filesystem with components", async () => {
const circuitWebWorker = await createCircuitWebWorker({
webWorkerUrl: new URL("../webworker/index.ts", import.meta.url),
})
await circuitWebWorker.executeWithFsMap({
fsMap: {
"entrypoint.tsx": `
import { MyLed } from "./myled.tsx"
import someJson from "./some.json"
circuit.add(
)
`,
"myled.tsx": `
import { RedLed } from "@tsci/seveibar.red-led"
export const MyLed = ({ name }) => {
return
}
`,
"some.json": `
{
"some": "value"
}
`,
},
entrypoint: "entrypoint.tsx",
})
await circuitWebWorker.renderUntilSettled()
const circuitJson = await circuitWebWorker.getCircuitJson()
const led = circuitJson.find((el: any) => el.name === "LED1")
expect(led?.type).toBe("source_component")
})