@@ -278,3 +278,25 @@ test("callbacks are called when appropriate for prototype based state machine",
278278
279279
280280
281+ //-----------------------------------------------------------------------------
282+
283+ test ( "double wildcard transition does not change current state" , function ( ) {
284+
285+ var fsm = StateMachine . create ( {
286+ initial : 'green' ,
287+ events : [
288+ { name : 'warn' , from : 'green' , to : 'yellow' } ,
289+ { name : 'panic' , from : [ 'green' , 'yellow' ] , to : 'red' } ,
290+ { name : 'noop' , from : [ 'green' , 'yellow' ] } , // NOTE: 'to' not specified
291+ { name : 'calm' , from : 'red' , to : 'yellow' } ,
292+ { name : 'clear' , from : [ 'yellow' , 'red' ] , to : 'green' } ,
293+ { name : 'lightup' , from : '*' } , // Note: "double wildcard"
294+ { name : 'lightup' , from : 'green' , to : 'yellow' }
295+ ] } ) ;
296+
297+ equal ( fsm . current , 'green' , "start with correct state" ) ;
298+
299+ fsm . lightup ( ) ; equal ( fsm . current , 'yellow' , "lightup event should switch green to yellow" ) ;
300+ fsm . lightup ( ) ; equal ( fsm . current , 'yellow' , "lightup event should have no effect effect in other state than green" ) ;
301+
302+ } ) ;
0 commit comments