diff --git a/lib/components/base-components/NormalComponent/NormalComponent.ts b/lib/components/base-components/NormalComponent/NormalComponent.ts
index b8bb3387..7dd53002 100644
--- a/lib/components/base-components/NormalComponent/NormalComponent.ts
+++ b/lib/components/base-components/NormalComponent/NormalComponent.ts
@@ -101,9 +101,13 @@ export class NormalComponent<
}
get internallyConnectedPinNames(): string[][] {
- return (
+ const rawPins =
this._parsedProps.internallyConnectedPins ??
this.defaultInternallyConnectedPinNames
+ return rawPins.map((pinGroup: (string | number)[]) =>
+ pinGroup.map((pin: string | number) =>
+ typeof pin === "number" ? `pin${pin}` : pin,
+ ),
)
}
diff --git a/tests/components/normal-components/__snapshots__/internally-connected-pins-numbers-schematic.snap.svg b/tests/components/normal-components/__snapshots__/internally-connected-pins-numbers-schematic.snap.svg
new file mode 100644
index 00000000..0ba96c75
--- /dev/null
+++ b/tests/components/normal-components/__snapshots__/internally-connected-pins-numbers-schematic.snap.svg
@@ -0,0 +1,20 @@
+
\ No newline at end of file
diff --git a/tests/components/normal-components/__snapshots__/jumper-numbers-internally-connected-schematic.snap.svg b/tests/components/normal-components/__snapshots__/jumper-numbers-internally-connected-schematic.snap.svg
new file mode 100644
index 00000000..74dd8cc9
--- /dev/null
+++ b/tests/components/normal-components/__snapshots__/jumper-numbers-internally-connected-schematic.snap.svg
@@ -0,0 +1,20 @@
+
\ No newline at end of file
diff --git a/tests/components/normal-components/internally-connected-pins-numbers.test.tsx b/tests/components/normal-components/internally-connected-pins-numbers.test.tsx
new file mode 100644
index 00000000..a997a831
--- /dev/null
+++ b/tests/components/normal-components/internally-connected-pins-numbers.test.tsx
@@ -0,0 +1,105 @@
+import { test, expect } from "bun:test"
+import { getTestFixture } from "tests/fixtures/get-test-fixture"
+
+test("internallyConnectedPins with numbers should convert to pin names", async () => {
+ const { circuit } = getTestFixture()
+
+ circuit.add(
+
+ {/* Test with pure numbers */}
+
+
+ {/* Test with mixed strings and numbers */}
+
+
+ {/* Test with pure strings */}
+
+ ,
+ )
+
+ await circuit.renderUntilSettled()
+
+ // Check that all pushbuttons were processed correctly
+ const sw1 = circuit.selectOne("pushbutton.SW1") as any
+ const sw2 = circuit.selectOne("pushbutton.SW2") as any
+ const sw3 = circuit.selectOne("pushbutton.SW3") as any
+
+ // Verify internal connections for SW1 (numbers)
+ const sw1InternalPins = sw1._getInternallyConnectedPins()
+ expect(sw1InternalPins).toHaveLength(2)
+ expect(sw1InternalPins[0].map((p: any) => p.props.name).sort()).toEqual([
+ "pin1",
+ "pin2",
+ ])
+ expect(sw1InternalPins[1].map((p: any) => p.props.name).sort()).toEqual([
+ "pin3",
+ "pin4",
+ ])
+
+ // Verify internal connections for SW2 (mixed)
+ const sw2InternalPins = sw2._getInternallyConnectedPins()
+ expect(sw2InternalPins).toHaveLength(2)
+ expect(sw2InternalPins[0].map((p: any) => p.props.name).sort()).toEqual([
+ "pin1",
+ "pin2",
+ ])
+ expect(sw2InternalPins[1].map((p: any) => p.props.name).sort()).toEqual([
+ "pin3",
+ "pin4",
+ ])
+
+ // Verify internal connections for SW3 (strings)
+ const sw3InternalPins = sw3._getInternallyConnectedPins()
+ expect(sw3InternalPins).toHaveLength(2)
+ expect(sw3InternalPins[0].map((p: any) => p.props.name).sort()).toEqual([
+ "pin1",
+ "pin2",
+ ])
+ expect(sw3InternalPins[1].map((p: any) => p.props.name).sort()).toEqual([
+ "pin3",
+ "pin4",
+ ])
+
+ // Verify the internallyConnectedPinNames getter processes numbers correctly
+ expect(sw1.internallyConnectedPinNames).toEqual([
+ ["pin1", "pin2"],
+ ["pin3", "pin4"],
+ ])
+ expect(sw2.internallyConnectedPinNames).toEqual([
+ ["pin1", "pin2"],
+ ["pin3", "pin4"],
+ ])
+ expect(sw3.internallyConnectedPinNames).toEqual([
+ ["pin1", "pin2"],
+ ["pin3", "pin4"],
+ ])
+
+ expect(circuit).toMatchSchematicSnapshot(import.meta.path)
+})
diff --git a/tests/components/normal-components/jumper-numbers-internally-connected.test.tsx b/tests/components/normal-components/jumper-numbers-internally-connected.test.tsx
new file mode 100644
index 00000000..d0e9b2d3
--- /dev/null
+++ b/tests/components/normal-components/jumper-numbers-internally-connected.test.tsx
@@ -0,0 +1,75 @@
+import { test, expect } from "bun:test"
+import { getTestFixture } from "tests/fixtures/get-test-fixture"
+
+test("jumper internallyConnectedPins with numbers should work correctly", async () => {
+ const { circuit } = getTestFixture()
+
+ circuit.add(
+
+ {/* Test jumper with numbers */}
+
+
+ {/* Test jumper with mixed strings and numbers */}
+
+
+ {/* Test jumper with pure strings (existing behavior) */}
+
+ ,
+ )
+
+ await circuit.renderUntilSettled()
+
+ // Check that all jumpers were processed correctly
+ const jp1 = circuit.selectOne("jumper.JP1") as any
+ const jp2 = circuit.selectOne("jumper.JP2") as any
+ const jp3 = circuit.selectOne("jumper.JP3") as any
+
+ // Verify internal connections for JP1 (numbers)
+ const jp1InternalPins = jp1._getInternallyConnectedPins()
+ expect(jp1InternalPins).toHaveLength(1)
+ expect(jp1InternalPins[0].map((p: any) => p.props.name).sort()).toEqual([
+ "pin1",
+ "pin2",
+ ])
+
+ // Verify internal connections for JP2 (mixed)
+ const jp2InternalPins = jp2._getInternallyConnectedPins()
+ expect(jp2InternalPins).toHaveLength(1)
+ expect(jp2InternalPins[0].map((p: any) => p.props.name).sort()).toEqual([
+ "pin1",
+ "pin2",
+ ])
+
+ // Verify internal connections for JP3 (strings)
+ const jp3InternalPins = jp3._getInternallyConnectedPins()
+ expect(jp3InternalPins).toHaveLength(1)
+ expect(jp3InternalPins[0].map((p: any) => p.props.name).sort()).toEqual([
+ "pin1",
+ "pin2",
+ ])
+
+ // Verify the internallyConnectedPinNames getter processes numbers correctly
+ expect(jp1.internallyConnectedPinNames).toEqual([["pin1", "pin2"]])
+ expect(jp2.internallyConnectedPinNames).toEqual([["pin1", "pin2"]])
+ expect(jp3.internallyConnectedPinNames).toEqual([["pin1", "pin2"]])
+
+ expect(circuit).toMatchSchematicSnapshot(import.meta.path)
+})