forked from tscircuit/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add usage of createElement from React.createElement (tscircuit#511)
* add usage of createElement from React.createElement * Update lib/index.ts --------- Co-authored-by: Severin Ibarluzea <[email protected]>
- Loading branch information
1 parent
9175e1f
commit 034efa1
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { it, expect } from "bun:test" | ||
import "lib/register-catalogue" | ||
import { Circuit, createElement } from "../index" | ||
|
||
it("should allow usage of createElement without explicit React import", () => { | ||
const circuit = new Circuit() | ||
const groupElm = createElement( | ||
"group", | ||
{}, | ||
createElement("led", { name: "LED2", footprint: "0402" }), | ||
createElement("resistor", { | ||
name: "R1", | ||
resistance: "10k", | ||
footprint: "0402", | ||
}), | ||
) | ||
|
||
circuit.add(groupElm) | ||
circuit.render() | ||
|
||
// Check that the circuit has the LED and resistor | ||
expect(circuit.db.source_component.select(".LED2")?.name).toBe("LED2") | ||
expect(circuit.db.source_component.select(".R1")?.name).toBe("R1") | ||
}) |