File tree Expand file tree Collapse file tree 4 files changed +27
-10
lines changed
tests/components/normal-components Expand file tree Collapse file tree 4 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -39,3 +39,4 @@ export { PushButton } from "./normal-components/PushButton"
39
39
export { Crystal } from "./normal-components/Crystal"
40
40
export { Transistor } from "./normal-components/Transistor"
41
41
export { Mosfet } from "./normal-components/Mosfet"
42
+ export { Switch } from "./normal-components/Switch"
Original file line number Diff line number Diff line change @@ -4,14 +4,17 @@ import type { BaseSymbolName } from "lib/utils/constants"
4
4
5
5
export class Switch extends NormalComponent < typeof switchProps > {
6
6
get config ( ) {
7
- const baseSymbolName : BaseSymbolName =
8
- this . props . type === "spst"
9
- ? "SPST_switch"
10
- : this . props . type === "spdt"
11
- ? "SPDT_switch"
12
- : this . props . type === "dpst"
13
- ? "dpst_switch"
14
- : "dpdt_switch"
7
+ let baseSymbolName : BaseSymbolName
8
+
9
+ if ( this . props . type === "spst" ) {
10
+ baseSymbolName = "SPST_switch"
11
+ } else if ( this . props . type === "spdt" ) {
12
+ baseSymbolName = "SPDT_switch"
13
+ } else if ( this . props . type === "dpst" ) {
14
+ baseSymbolName = "dpst_switch"
15
+ } else {
16
+ baseSymbolName = "dpdt_switch"
17
+ }
15
18
16
19
return {
17
20
componentName : "Switch" ,
@@ -26,12 +29,11 @@ export class Switch extends NormalComponent<typeof switchProps> {
26
29
const { _parsedProps : props } = this
27
30
28
31
const source_component = db . source_component . insert ( {
29
- ftype : "switch " ,
32
+ ftype : "simple_switch " ,
30
33
name : props . name ,
31
34
switch_type : props . type ,
32
35
is_normally_closed : props . isNormallyClosed ,
33
36
} as any )
34
-
35
37
this . source_component_id = source_component . source_component_id
36
38
}
37
39
}
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ export interface TscircuitElements {
47
47
resonator : Props . ResonatorProps
48
48
subcircuit : Props . SubcircuitGroupProps
49
49
transistor : Props . TransistorProps
50
+ switch : Props . SwitchProps
50
51
mosfet : Props . MosfetProps
51
52
jscad : any
52
53
}
Original file line number Diff line number Diff line change
1
+ import { it , expect } from "bun:test"
2
+ import { getTestFixture } from "tests/fixtures/get-test-fixture"
3
+
4
+ it ( "should render an switch" , async ( ) => {
5
+ const { circuit } = getTestFixture ( )
6
+ circuit . add (
7
+ < board width = "10mm" height = "10mm" >
8
+ < switch name = "switch" type = "spst" />
9
+ </ board > ,
10
+ )
11
+ circuit . render ( )
12
+ expect ( circuit ) . toMatchSchematicSnapshot ( import . meta. path )
13
+ } )
You can’t perform that action at this time.
0 commit comments