@@ -490,6 +490,45 @@ describe("actions", () => {
490
490
} ) ;
491
491
} ) ;
492
492
} ) ;
493
+ describe ( "Timeout" , ( ) => {
494
+ const actionID = ActionID . Timeout ;
495
+ const validOrigin = [
496
+ StateID . AppearTriggered , StateID . AppearStarted ,
497
+ StateID . EnterTriggered , StateID . EnterStarted ,
498
+ StateID . LeaveTriggered , StateID . LeaveStarted ,
499
+ ] ;
500
+
501
+ it ( "should fail on invalid state transitions" , ( ) => {
502
+ StateIDList
503
+ . filter ( ( id ) => validOrigin . indexOf ( id ) < 0 )
504
+ . forEach ( ( id ) => assert . throw ( ( ) => reducer ( id , { kind : actionID , props : { } } ) ) ) ;
505
+ } ) ;
506
+ it ( "should transit to active state" , ( ) => {
507
+ const origin = [
508
+ StateID . AppearTriggered , StateID . AppearStarted ,
509
+ StateID . EnterTriggered , StateID . EnterStarted ,
510
+ ] ;
511
+ origin . forEach ( ( id ) => {
512
+ const { state, pending} = reducer ( id , { kind : actionID , props : { } } ) ;
513
+ assert . isUndefined ( pending ) ;
514
+ assert . strictEqual ( state . id , StateID . Active ) ;
515
+ } ) ;
516
+ } ) ;
517
+ it ( "should transit to default state" , ( ) => {
518
+ [ StateID . LeaveTriggered , StateID . LeaveStarted ] . forEach ( ( id ) => {
519
+ const { state, pending} = reducer ( id , { kind : actionID , props : { } } ) ;
520
+ assert . isUndefined ( pending ) ;
521
+ assert . strictEqual ( state . id , StateID . Default ) ;
522
+ } ) ;
523
+ } ) ;
524
+ it ( "should complete" , ( ) => {
525
+ validOrigin . forEach ( ( id ) => {
526
+ const result = reducer ( id , { kind : actionID , props : { } } ) ;
527
+ assert . isTrue ( result . completed ) ;
528
+ } ) ;
529
+ } ) ;
530
+ } ) ;
531
+
493
532
describe ( "TransitionTrigger" , ( ) => {
494
533
const actionID = ActionID . TransitionTrigger ;
495
534
it ( "should transit to enter init state" , ( ) => {
0 commit comments