@@ -20,10 +20,10 @@ import {
2020 removeEdge ,
2121 removeNode ,
2222 setAuthority ,
23+ setConfig ,
2324 setEdge ,
2425 setLegend ,
2526 setNodePosition ,
26- setProps ,
2727} from "@/schematic/actions.gen" ;
2828import { ZERO_LEGEND } from "@/schematic/client" ;
2929import { type Edge , type Node , type Schematic } from "@/schematic/types.gen" ;
@@ -53,7 +53,7 @@ const empty = (overrides: Partial<Schematic> = {}): Schematic => ({
5353 legend : ZERO_LEGEND ,
5454 nodes : [ ] ,
5555 edges : [ ] ,
56- props : { } ,
56+ configs : { } ,
5757 ...overrides ,
5858} ) ;
5959
@@ -89,15 +89,15 @@ describe("schematic reducer", () => {
8989 const out = reduceAll ( state , [ addNode ( { node : node ( "n2" , 1 , 2 ) } ) ] ) ;
9090 expect ( out . nodes ) . toEqual ( [ node ( "n1" , 0 , 0 ) , node ( "n2" , 1 , 2 ) ] ) ;
9191 } ) ;
92- it ( "should write props under the node's key when props is non-undefined" , ( ) => {
92+ it ( "should write config under the node's key when config is non-undefined" , ( ) => {
9393 const out = reduceAll ( empty ( ) , [
94- addNode ( { node : node ( "n1" , 0 , 0 ) , props : { label : "Pump" , color : "#f00" } } ) ,
94+ addNode ( { node : node ( "n1" , 0 , 0 ) , config : { label : "Pump" , color : "#f00" } } ) ,
9595 ] ) ;
96- expect ( out . props ) . toEqual ( { n1 : { label : "Pump" , color : "#f00" } } ) ;
96+ expect ( out . configs ) . toEqual ( { n1 : { label : "Pump" , color : "#f00" } } ) ;
9797 } ) ;
98- it ( "should leave props untouched when the action's props is undefined" , ( ) => {
98+ it ( "should leave configs untouched when the action's config is undefined" , ( ) => {
9999 const out = reduceAll ( empty ( ) , [ addNode ( { node : node ( "n1" , 0 , 0 ) } ) ] ) ;
100- expect ( out . props ) . toEqual ( { } ) ;
100+ expect ( out . configs ) . toEqual ( { } ) ;
101101 } ) ;
102102 it ( "should append a duplicate-key node, locking current behavior" , ( ) => {
103103 const state = empty ( { nodes : [ node ( "n1" , 0 , 0 ) ] } ) ;
@@ -109,14 +109,14 @@ describe("schematic reducer", () => {
109109 } ) ;
110110
111111 describe ( "removeNode" , ( ) => {
112- it ( "should remove the matching node and any props stored under its key" , ( ) => {
112+ it ( "should remove the matching node and any config stored under its key" , ( ) => {
113113 const state = empty ( {
114114 nodes : [ node ( "n1" , 0 , 0 ) , node ( "n2" , 1 , 1 ) ] ,
115- props : { n1 : { label : "Pump" } , n2 : { label : "Tank" } } ,
115+ configs : { n1 : { label : "Pump" } , n2 : { label : "Tank" } } ,
116116 } ) ;
117117 const out = reduceAll ( state , [ removeNode ( { key : "n1" } ) ] ) ;
118118 expect ( out . nodes ) . toEqual ( [ node ( "n2" , 1 , 1 ) ] ) ;
119- expect ( out . props ) . toEqual ( { n2 : { label : "Tank" } } ) ;
119+ expect ( out . configs ) . toEqual ( { n2 : { label : "Tank" } } ) ;
120120 } ) ;
121121 it ( "should leave existing edges intact even when they reference the removed node" , ( ) => {
122122 const state = empty ( {
@@ -130,11 +130,11 @@ describe("schematic reducer", () => {
130130 it ( "should be a no-op when the key does not match any node" , ( ) => {
131131 const state = empty ( {
132132 nodes : [ node ( "n1" , 0 , 0 ) ] ,
133- props : { n1 : { label : "Pump" } } ,
133+ configs : { n1 : { label : "Pump" } } ,
134134 } ) ;
135135 const out = reduceAll ( state , [ removeNode ( { key : "ghost" } ) ] ) ;
136136 expect ( out . nodes ) . toEqual ( state . nodes ) ;
137- expect ( out . props ) . toEqual ( state . props ) ;
137+ expect ( out . configs ) . toEqual ( state . configs ) ;
138138 } ) ;
139139 } ) ;
140140
@@ -176,21 +176,25 @@ describe("schematic reducer", () => {
176176 } ) ;
177177 } ) ;
178178
179- describe ( "setProps " , ( ) => {
180- it ( "should write the props entry under the given key" , ( ) => {
179+ describe ( "setConfig " , ( ) => {
180+ it ( "should write the config entry under the given key" , ( ) => {
181181 const out = reduceAll ( empty ( ) , [
182- setProps ( { key : "n1" , props : { label : "Pump" } } ) ,
182+ setConfig ( { key : "n1" , config : { label : "Pump" } } ) ,
183183 ] ) ;
184- expect ( out . props ) . toEqual ( { n1 : { label : "Pump" } } ) ;
184+ expect ( out . configs ) . toEqual ( { n1 : { label : "Pump" } } ) ;
185185 } ) ;
186- it ( "should overwrite an existing props entry" , ( ) => {
187- const state = empty ( { props : { n1 : { label : "Old" } } } ) ;
188- const out = reduceAll ( state , [ setProps ( { key : "n1" , props : { label : "New" } } ) ] ) ;
189- expect ( out . props ) . toEqual ( { n1 : { label : "New" } } ) ;
186+ it ( "should overwrite an existing config entry" , ( ) => {
187+ const state = empty ( { configs : { n1 : { label : "Old" } } } ) ;
188+ const out = reduceAll ( state , [
189+ setConfig ( { key : "n1" , config : { label : "New" } } ) ,
190+ ] ) ;
191+ expect ( out . configs ) . toEqual ( { n1 : { label : "New" } } ) ;
190192 } ) ;
191193 it ( "should accept a key that does not match any node or edge" , ( ) => {
192- const out = reduceAll ( empty ( ) , [ setProps ( { key : "orphan" , props : { data : 1 } } ) ] ) ;
193- expect ( out . props ) . toEqual ( { orphan : { data : 1 } } ) ;
194+ const out = reduceAll ( empty ( ) , [
195+ setConfig ( { key : "orphan" , config : { data : 1 } } ) ,
196+ ] ) ;
197+ expect ( out . configs ) . toEqual ( { orphan : { data : 1 } } ) ;
194198 } ) ;
195199 } ) ;
196200
@@ -254,30 +258,30 @@ describe("schematic reducer", () => {
254258 addNode ( { node : node ( "tank" , 200 , 0 ) } ) ,
255259 setEdge ( { edge : edge ( "e1" , "pump" , "out" , "valve" , "in" ) } ) ,
256260 setEdge ( { edge : edge ( "e2" , "valve" , "out" , "tank" , "in" ) } ) ,
257- setProps ( { key : "pump" , props : { label : "Main Pump" } } ) ,
258- setProps ( { key : "e1" , props : { variant : "pipe" } } ) ,
261+ setConfig ( { key : "pump" , config : { label : "Main Pump" } } ) ,
262+ setConfig ( { key : "e1" , config : { variant : "pipe" } } ) ,
259263 ] ) ;
260264 expect ( out . nodes ) . toHaveLength ( 3 ) ;
261265 expect ( out . edges ) . toHaveLength ( 2 ) ;
262- expect ( out . props ) . toEqual ( {
266+ expect ( out . configs ) . toEqual ( {
263267 pump : { label : "Main Pump" } ,
264268 e1 : { variant : "pipe" } ,
265269 } ) ;
266270 } ) ;
267271
268- it ( "should drop props but keep dangling edges when a node is removed and re-added" , ( ) => {
272+ it ( "should drop config but keep dangling edges when a node is removed and re-added" , ( ) => {
269273 const state = empty ( {
270274 nodes : [ node ( "n1" , 0 , 0 ) , node ( "n2" , 1 , 1 ) ] ,
271275 edges : [ edge ( "e1" , "n1" , "o" , "n2" , "i" ) ] ,
272- props : { n1 : { label : "v1" } } ,
276+ configs : { n1 : { label : "v1" } } ,
273277 } ) ;
274278 const out = reduceAll ( state , [
275279 removeNode ( { key : "n1" } ) ,
276280 addNode ( { node : node ( "n1" , 50 , 50 ) } ) ,
277281 ] ) ;
278282 expect ( out . nodes ) . toHaveLength ( 2 ) ;
279283 expect ( out . nodes [ 1 ] ) . toEqual ( node ( "n1" , 50 , 50 ) ) ;
280- expect ( out . props ) . toEqual ( { } ) ;
284+ expect ( out . configs ) . toEqual ( { } ) ;
281285 expect ( out . edges ) . toHaveLength ( 1 ) ;
282286 expect ( out . edges [ 0 ] . source . node ) . toBe ( "n1" ) ;
283287 } ) ;
@@ -308,8 +312,8 @@ describe("schematic reducer", () => {
308312 } ) ,
309313 ) ;
310314 for ( let i = 0 ; i < 3 ; i ++ )
311- actions . push ( setProps ( { key : `n${ i } ` , props : { label : `node ${ i } ` } } ) ) ;
312- actions . push ( setProps ( { key : "e1" , props : { variant : "electric" } } ) ) ;
315+ actions . push ( setConfig ( { key : `n${ i } ` , config : { label : `node ${ i } ` } } ) ) ;
316+ actions . push ( setConfig ( { key : "e1" , config : { variant : "electric" } } ) ) ;
313317 actions . push ( setAuthority ( { value : 255 } ) ) ;
314318 actions . push (
315319 setLegend ( {
@@ -321,7 +325,7 @@ describe("schematic reducer", () => {
321325 expect ( out . nodes [ 0 ] . position ) . toEqual ( { x : 0 , y : 100 } ) ;
322326 expect ( out . nodes [ 4 ] . position ) . toEqual ( { x : 400 , y : 100 } ) ;
323327 expect ( out . edges ) . toHaveLength ( 4 ) ;
324- expect ( Object . keys ( out . props ) ) . toHaveLength ( 4 ) ;
328+ expect ( Object . keys ( out . configs ) ) . toHaveLength ( 4 ) ;
325329 expect ( out . authority ) . toBe ( 255 ) ;
326330 expect ( out . legend . visible ) . toBe ( true ) ;
327331 } ) ;
0 commit comments