11import { IAction , createOvermind } from '../'
2- import { Statechart , statecharts } from './'
2+ import { Statechart , statechart } from './'
33
44describe ( 'Statecharts' , ( ) => {
55 test ( 'should wrap configs' , ( ) => {
@@ -13,7 +13,7 @@ describe('Statecharts', () => {
1313 foo : { } ,
1414 } ,
1515 }
16- const instance = createOvermind ( statecharts ( config , {
16+ const instance = createOvermind ( statechart ( config , {
1717 id1 : chart
1818 } ) )
1919
@@ -26,7 +26,7 @@ describe('Statecharts', () => {
2626 } ) ) . toEqual ( true )
2727 } )
2828
29- test . only ( 'should allow root chart' , ( ) => {
29+ test ( 'should allow root chart' , ( ) => {
3030 const config = { }
3131
3232 const chart : Statechart < typeof config , {
@@ -37,9 +37,9 @@ describe('Statecharts', () => {
3737 foo : { } ,
3838 } ,
3939 }
40- const instance = createOvermind ( statecharts ( config , chart ) )
40+ const instance = createOvermind ( statechart ( config , chart ) )
4141
42- expect ( instance . state . states ) . toEqual ( [ [ 'ROOT_CHART ' , 'foo' ] ] )
42+ expect ( instance . state . states ) . toEqual ( [ [ 'CHART ' , 'foo' ] ] )
4343 expect ( instance . state . actions ) . toEqual ( { } )
4444 expect ( instance . state . matches ( {
4545 foo : true
@@ -78,7 +78,7 @@ describe('Statecharts', () => {
7878 interface Action < Input = void , Output = void >
7979 extends IAction < typeof config , Input , Output > { }
8080
81- const instance = createOvermind ( statecharts ( config , {
81+ const instance = createOvermind ( statechart ( config , {
8282 id1 : chart
8383 } ) )
8484
@@ -130,7 +130,7 @@ describe('Statecharts', () => {
130130 interface Action < Input = void , Output = void >
131131 extends IAction < typeof config , Input , Output > { }
132132
133- const instance = createOvermind ( statecharts ( config , {
133+ const instance = createOvermind ( statechart ( config , {
134134 id1 : chart
135135 } ) )
136136
@@ -179,7 +179,7 @@ describe('Statecharts', () => {
179179 interface Action < Input = void , Output = void >
180180 extends IAction < typeof config , Input , Output > { }
181181
182- const instance = createOvermind ( statecharts ( config , {
182+ const instance = createOvermind ( statechart ( config , {
183183 id1 : chart
184184 } ) )
185185
@@ -247,7 +247,7 @@ describe('Statecharts', () => {
247247 interface Action < Input = void , Output = void >
248248 extends IAction < typeof config , Input , Output > { }
249249
250- const instance = createOvermind ( statecharts ( config , {
250+ const instance = createOvermind ( statechart ( config , {
251251 id1 : chart
252252 } ) )
253253
@@ -283,7 +283,7 @@ describe('Statecharts', () => {
283283 } ) ) . toEqual ( true )
284284 } )
285285
286- test ( 'should allow nesting' , ( ) => {
286+ test . only ( 'should allow nesting' , ( ) => {
287287 const fooEntry : Action = ( { state } ) => {
288288 state . transitions . push ( 'fooEntry' )
289289 }
@@ -337,9 +337,7 @@ describe('Statecharts', () => {
337337 }
338338
339339 const chart : Statechart < typeof config , {
340- foo : {
341- nested : typeof nestedChart
342- } ,
340+ foo : typeof nestedChart ,
343341 bar : void
344342 } > = {
345343 initial : 'foo' ,
@@ -350,7 +348,7 @@ describe('Statecharts', () => {
350348 on : {
351349 changeToBar : 'bar' ,
352350 } ,
353- charts : { nested : nestedChart } ,
351+ chart : nestedChart
354352 } ,
355353 bar : { } ,
356354 } ,
@@ -359,11 +357,9 @@ describe('Statecharts', () => {
359357 interface Action < Input = void , Output = void >
360358 extends IAction < typeof config , Input , Output > { }
361359
362- const instance = createOvermind ( statecharts ( config , {
363- test : chart
364- } ) )
360+ const instance = createOvermind ( statechart ( config , chart ) )
365361
366- expect ( instance . state . states ) . toEqual ( [ [ 'test ' , 'foo' , 'nested ' , 'a' ] ] )
362+ expect ( instance . state . states ) . toEqual ( [ [ 'CHART ' , 'foo' , 'CHART ' , 'a' ] ] )
367363 expect ( instance . state . actions ) . toEqual ( {
368364 fooEntry : false ,
369365 fooExit : false ,
@@ -376,7 +372,7 @@ describe('Statecharts', () => {
376372 expect ( instance . state . transitions ) . toEqual ( [ 'aEntry' , 'fooEntry' ] )
377373 instance . actions . changeToB ( )
378374
379- expect ( instance . state . states ) . toEqual ( [ [ 'test ' , 'foo' , 'nested ' , 'b' ] ] )
375+ expect ( instance . state . states ) . toEqual ( [ [ 'CHART ' , 'foo' , 'CHART ' , 'b' ] ] )
380376 expect ( instance . state . actions ) . toEqual ( {
381377 fooEntry : false ,
382378 fooExit : false ,
@@ -388,7 +384,7 @@ describe('Statecharts', () => {
388384 } )
389385 expect ( instance . state . transitions ) . toEqual ( [ 'aEntry' , 'fooEntry' , 'aExit' ] )
390386 instance . actions . changeToBar ( )
391- expect ( instance . state . states ) . toEqual ( [ [ 'test ' , 'bar' ] ] )
387+ expect ( instance . state . states ) . toEqual ( [ [ 'CHART ' , 'bar' ] ] )
392388 expect ( instance . state . actions ) . toEqual ( {
393389 fooEntry : false ,
394390 fooExit : false ,
@@ -458,7 +454,7 @@ describe('Statecharts', () => {
458454 extends IAction < typeof config , Input , Output > { }
459455
460456 const instance = createOvermind (
461- statecharts ( config , { chartA, chartB} )
457+ statechart ( config , { chartA, chartB} )
462458 )
463459
464460 expect ( instance . state . states ) . toEqual ( [ [ 'chartA' , 'bar' ] , [ 'chartB' , 'foo' ] ] )
@@ -557,7 +553,7 @@ describe('Statecharts', () => {
557553 increaseCount : null ,
558554 changeToBar : 'bar' ,
559555 } ,
560- charts : { nestedChartB} ,
556+ chart : { nestedChartB} ,
561557 } ,
562558 bar : { } ,
563559 } ,
@@ -567,7 +563,7 @@ describe('Statecharts', () => {
567563 extends IAction < typeof config , Input , Output > { }
568564
569565 const instance = createOvermind (
570- statecharts ( config , { parallelChartA, parallelChartB} )
566+ statechart ( config , { parallelChartA, parallelChartB} )
571567 )
572568
573569 expect ( instance . state . states ) . toEqual ( [ [ 'parallelChartA' , 'bar' ] , [ 'parallelChartB' , 'foo' , 'nestedChartB' , 'foo' ] ] )
@@ -663,7 +659,7 @@ describe('Statecharts', () => {
663659 on : {
664660 changeToBar : 'bar' ,
665661 } ,
666- charts : { chart, chartB} ,
662+ chart : { chart, chartB} ,
667663 } ,
668664 bar : { } ,
669665 } ,
@@ -672,7 +668,7 @@ describe('Statecharts', () => {
672668 interface Action < Input = void , Output = void >
673669 extends IAction < typeof config , Input , Output > { }
674670
675- const instance = createOvermind ( statecharts ( config , { mainChart} ) )
671+ const instance = createOvermind ( statechart ( config , { mainChart} ) )
676672
677673 expect ( instance . state . states ) . toEqual ( [ [ 'mainChart' , 'foo' , 'chart' , 'baz' ] , [ 'mainChart' , 'foo' , 'chartB' , 'baz' ] ] )
678674 expect ( instance . state . actions ) . toEqual ( { increaseCount : false , changeToBar : true } )
@@ -704,7 +700,7 @@ describe('Statecharts', () => {
704700 expect ( instance . state . count ) . toBe ( 3 )
705701 } )
706702
707- test . only ( 'should run entry and exit actions when transitioning within a transition' , async ( ) => {
703+ test ( 'should run entry and exit actions when transitioning within a transition' , async ( ) => {
708704 const step : AsyncAction = async ( { state, actions } ) => {
709705 state . actionEvents . push ( 'step' )
710706 await Promise . resolve ( )
@@ -760,7 +756,7 @@ describe('Statecharts', () => {
760756 interface AsyncAction < Input = void , Output = void >
761757 extends IAction < typeof config , Input , Promise < Output > > { }
762758
763- const instance = createOvermind ( statecharts ( config , {
759+ const instance = createOvermind ( statechart ( config , {
764760 id1 : chart
765761 } ) )
766762
0 commit comments