@@ -34,16 +34,16 @@ describe("xstate-tree builders", () => {
3434 const hist : XstateTreeHistory = createMemoryHistory ( ) ;
3535 const createRoute = buildCreateRoute ( ( ) => hist , "/" ) ;
3636
37- const fooRoute = createRoute . simpleRoute ( ) ( {
38- url : "/foo/" ,
39- event : "GO_TO_FOO" ,
40- } ) ;
41- const barRoute = createRoute . simpleRoute ( ) ( {
42- url : "/bar/" ,
43- event : "GO_TO_BAR" ,
44- } ) ;
45-
4637 it ( "takes a mapping of routes to machines and returns a machine that invokes those machines when those routes events are broadcast" , async ( ) => {
38+ const fooRoute = createRoute . simpleRoute ( ) ( {
39+ url : "/foo/" ,
40+ event : "GO_TO_FOO" ,
41+ } ) ;
42+ const barRoute = createRoute . simpleRoute ( ) ( {
43+ url : "/bar/" ,
44+ event : "GO_TO_BAR" ,
45+ } ) ;
46+
4747 const FooMachine = viewToMachine ( ( ) => < div > foo</ div > ) ;
4848 const BarMachine = viewToMachine ( ( ) => < div > bar</ div > ) ;
4949
@@ -66,5 +66,38 @@ describe("xstate-tree builders", () => {
6666 act ( ( ) => barRoute . navigate ( ) ) ;
6767 await waitFor ( ( ) => getByText ( "bar" ) ) ;
6868 } ) ;
69+
70+ it ( "handles routing events that contain . in them" , async ( ) => {
71+ const fooRoute = createRoute . simpleRoute ( ) ( {
72+ url : "/foo/" ,
73+ event : "routing.foo" ,
74+ } ) ;
75+ const barRoute = createRoute . simpleRoute ( ) ( {
76+ url : "/bar/" ,
77+ event : "routing.bar" ,
78+ } ) ;
79+
80+ const FooMachine = viewToMachine ( ( ) => < div > foo</ div > ) ;
81+ const BarMachine = viewToMachine ( ( ) => < div > bar</ div > ) ;
82+
83+ const routingMachine = buildRoutingMachine ( [ fooRoute , barRoute ] , {
84+ "routing.foo" : FooMachine ,
85+ "routing.bar" : BarMachine ,
86+ } ) ;
87+
88+ const Root = buildRootComponent ( routingMachine , {
89+ history : hist ,
90+ basePath : "/" ,
91+ routes : [ fooRoute , barRoute ] ,
92+ } ) ;
93+
94+ const { getByText } = render ( < Root /> ) ;
95+
96+ act ( ( ) => fooRoute . navigate ( ) ) ;
97+ await waitFor ( ( ) => getByText ( "foo" ) ) ;
98+
99+ act ( ( ) => barRoute . navigate ( ) ) ;
100+ await waitFor ( ( ) => getByText ( "bar" ) ) ;
101+ } ) ;
69102 } ) ;
70103} ) ;
0 commit comments