@@ -4,9 +4,9 @@ import { transit } from "./transit";
4
4
import {
5
5
reducer , StateID , StateIDList , ActionID , ActionProps , TransitionState , getState ,
6
6
getDelay , transitionNames , hasTransition ,
7
- defaultInitState , activeInitState , appearInitState ,
7
+ defaultNewState , activeNewState , appearNewState ,
8
8
defaultState , activeState ,
9
- appearPendingState , enterPendingState , leavePendingState ,
9
+ appearInitState , enterInitState , leaveInitState ,
10
10
appearPrepareState , enterPrepareState , leavePrepareState ,
11
11
appearTriggeredState , enterTriggeredState , leaveTriggeredState ,
12
12
appearStartedState , enterStartedState , leaveStartedState ,
@@ -69,7 +69,7 @@ describe("reducer.ts", () => {
69
69
} ) ;
70
70
it ( "should return transition init state" , ( ) => {
71
71
transitionNames . forEach ( ( name ) => {
72
- const id = StateID . EnterPending ;
72
+ const id = StateID . EnterInit ;
73
73
const inTransition = false ;
74
74
const style = { top : 0 } ;
75
75
const className = "foo" ;
@@ -115,7 +115,7 @@ describe("reducer.ts", () => {
115
115
it ( "should return transition init fallback state" , ( ) => {
116
116
transitionNames . forEach ( ( name ) => {
117
117
const fallbackName = name === "leave" ? "active" : "default" ;
118
- const id = StateID . EnterPending ;
118
+ const id = StateID . EnterInit ;
119
119
const inTransition = false ;
120
120
const style = { top : 0 } ;
121
121
const className = "foo" ;
@@ -203,7 +203,7 @@ describe("reducer.ts", () => {
203
203
} ) ;
204
204
} ) ;
205
205
it ( "should fallback appear to enter" , ( ) => {
206
- const id = StateID . AppearInit ;
206
+ const id = StateID . AppearNew ;
207
207
const style = { left : "0px" } ;
208
208
const className = "foo" ;
209
209
const inTransition = true ;
@@ -234,7 +234,7 @@ it("should fallback appear to enter", () => {
234
234
} ) ;
235
235
} ) ;
236
236
it ( "should fallback appearInit to enterInit" , ( ) => {
237
- const id = StateID . AppearInit ;
237
+ const id = StateID . AppearNew ;
238
238
const style = { left : "0px" } ;
239
239
const className = "foo" ;
240
240
const inTransition = false ;
@@ -266,16 +266,16 @@ it("should fallback appearInit to enterInit", () => {
266
266
} ) ;
267
267
describe ( "states" , ( ) => {
268
268
describe (
269
- "defaultInitState " ,
270
- testState ( StateID . DefaultInit , "defaultStyle" , ( props ) => defaultInitState ( props ) ) ,
269
+ "defaultNewState " ,
270
+ testState ( StateID . DefaultNew , "defaultStyle" , ( props ) => defaultNewState ( props ) ) ,
271
271
) ;
272
272
describe (
273
- "activeInitState " ,
274
- testState ( StateID . ActiveInit , "activeStyle" , ( props ) => activeInitState ( props ) ) ,
273
+ "activeNewState " ,
274
+ testState ( StateID . ActiveNew , "activeStyle" , ( props ) => activeNewState ( props ) ) ,
275
275
) ;
276
276
describe (
277
- "appearInitState " ,
278
- testState ( StateID . AppearInit , "appearInitStyle" , ( props ) => appearInitState ( props ) ) ,
277
+ "appearNewState " ,
278
+ testState ( StateID . AppearNew , "appearInitStyle" , ( props ) => appearNewState ( props ) ) ,
279
279
) ;
280
280
describe (
281
281
"defaultState" ,
@@ -286,16 +286,16 @@ describe("states", () => {
286
286
testState ( StateID . Active , "activeStyle" , ( props ) => activeState ( props ) ) ,
287
287
) ;
288
288
describe (
289
- "appearPendingState " ,
290
- testState ( StateID . AppearPending , "appearInitStyle" , ( props ) => appearPendingState ( props ) ) ,
289
+ "appearInitState " ,
290
+ testState ( StateID . AppearInit , "appearInitStyle" , ( props ) => appearInitState ( props ) ) ,
291
291
) ;
292
292
describe (
293
- "enterPendingState " ,
294
- testState ( StateID . EnterPending , "enterInitStyle" , ( props ) => enterPendingState ( props ) ) ,
293
+ "enterInitState " ,
294
+ testState ( StateID . EnterInit , "enterInitStyle" , ( props ) => enterInitState ( props ) ) ,
295
295
) ;
296
296
describe (
297
- "leavePendingState " ,
298
- testState ( StateID . LeavePending , "leaveInitStyle" , ( props ) => leavePendingState ( props ) ) ,
297
+ "leaveInitState " ,
298
+ testState ( StateID . LeaveInit , "leaveInitStyle" , ( props ) => leaveInitState ( props ) ) ,
299
299
) ;
300
300
describe (
301
301
"appearPrepareState" ,
@@ -335,44 +335,44 @@ describe("states", () => {
335
335
) ;
336
336
} ) ;
337
337
describe ( "actions" , ( ) => {
338
- describe ( "Init " , ( ) => {
339
- const actionID = ActionID . Init ;
338
+ describe ( "New " , ( ) => {
339
+ const actionID = ActionID . New ;
340
340
341
341
it ( "should fail when state is already initialized" , ( ) => {
342
342
assert . throw ( ( ) => reducer ( StateID . Active , { kind : actionID , props : { } } ) ) ;
343
343
} ) ;
344
- it ( "should become DefaultInit " , ( ) => {
344
+ it ( "should become DefaultNew " , ( ) => {
345
345
const { state, pending} = reducer ( StateID . EntryPoint , { kind : actionID , props : { active : false } } ) ;
346
346
assert . isUndefined ( pending ) ;
347
- assert . strictEqual ( state . id , StateID . DefaultInit ) ;
347
+ assert . strictEqual ( state . id , StateID . DefaultNew ) ;
348
348
} ) ;
349
- it ( "should become ActiveInit " , ( ) => {
349
+ it ( "should become ActiveNew " , ( ) => {
350
350
const { state, pending} = reducer ( StateID . EntryPoint , { kind : actionID , props : { active : true } } ) ;
351
351
assert . isUndefined ( pending ) ;
352
- assert . strictEqual ( state . id , StateID . ActiveInit ) ;
352
+ assert . strictEqual ( state . id , StateID . ActiveNew ) ;
353
353
} ) ;
354
- it ( "should become AppearInit " , ( ) => {
354
+ it ( "should become AppearNew " , ( ) => {
355
355
const { state, pending} = reducer ( StateID . EntryPoint , {
356
356
kind : actionID ,
357
357
props : {
358
358
active : true , transitionAppear : true ,
359
359
} ,
360
360
} ) ;
361
361
assert . isUndefined ( pending ) ;
362
- assert . strictEqual ( state . id , StateID . AppearInit ) ;
362
+ assert . strictEqual ( state . id , StateID . AppearNew ) ;
363
363
} ) ;
364
364
} ) ;
365
365
describe ( "Mount" , ( ) => {
366
366
const actionID = ActionID . Mount ;
367
- it ( "should become AppearPending " , ( ) => {
368
- const { state, pending} = reducer ( StateID . AppearInit , {
367
+ it ( "should become AppearInit " , ( ) => {
368
+ const { state, pending} = reducer ( StateID . AppearNew , {
369
369
kind : actionID ,
370
370
props : {
371
371
appearStyle : { } ,
372
372
} ,
373
373
} ) ;
374
374
assert . strictEqual ( pending , ActionID . TransitionPrepare ) ;
375
- assert . strictEqual ( state . id , StateID . AppearPending ) ;
375
+ assert . strictEqual ( state . id , StateID . AppearInit ) ;
376
376
} ) ;
377
377
378
378
it ( "should do nothing" , ( ) => {
@@ -382,44 +382,44 @@ describe("actions", () => {
382
382
describe ( "TransitionInit" , ( ) => {
383
383
const actionID = ActionID . TransitionInit ;
384
384
const validOrigin = [
385
- StateID . Active , StateID . ActiveInit , StateID . Default , StateID . DefaultInit , StateID . AppearInit ,
385
+ StateID . Active , StateID . ActiveNew , StateID . Default , StateID . DefaultNew , StateID . AppearNew ,
386
386
] ;
387
387
388
388
it ( "should fail on invalid state transitions" , ( ) => {
389
389
StateIDList
390
390
. filter ( ( id ) => validOrigin . indexOf ( id ) < 0 )
391
391
. forEach ( ( id ) => assert . throw ( ( ) => reducer ( id , { kind : actionID , props : { } } ) ) ) ;
392
392
} ) ;
393
- it ( "should transit to enter pending state" , ( ) => {
394
- [ StateID . Default , StateID . DefaultInit ] . forEach ( ( id ) => {
393
+ it ( "should transit to enter init state" , ( ) => {
394
+ [ StateID . Default , StateID . DefaultNew ] . forEach ( ( id ) => {
395
395
const { state, pending} = reducer ( id , { kind : actionID , props : { enterStyle : { } } } ) ;
396
396
assert . strictEqual ( pending , ActionID . TransitionPrepare ) ;
397
- assert . strictEqual ( state . id , StateID . EnterPending ) ;
397
+ assert . strictEqual ( state . id , StateID . EnterInit ) ;
398
398
} ) ;
399
399
} ) ;
400
- it ( "should transit to leave pending state" , ( ) => {
401
- [ StateID . Active , StateID . ActiveInit ] . forEach ( ( id ) => {
400
+ it ( "should transit to leave init state" , ( ) => {
401
+ [ StateID . Active , StateID . ActiveNew ] . forEach ( ( id ) => {
402
402
const { state, pending} = reducer ( id , { kind : actionID , props : { leaveStyle : { } } } ) ;
403
403
assert . strictEqual ( pending , ActionID . TransitionPrepare ) ;
404
- assert . strictEqual ( state . id , StateID . LeavePending ) ;
404
+ assert . strictEqual ( state . id , StateID . LeaveInit ) ;
405
405
} ) ;
406
406
} ) ;
407
- it ( "should transit to appear pending state" , ( ) => {
408
- const id = StateID . AppearInit ;
407
+ it ( "should transit to appear init state" , ( ) => {
408
+ const id = StateID . AppearNew ;
409
409
const { state, pending} = reducer ( id , { kind : actionID , props : { appearStyle : { } } } ) ;
410
410
assert . strictEqual ( pending , ActionID . TransitionPrepare ) ;
411
- assert . strictEqual ( state . id , StateID . AppearPending ) ;
411
+ assert . strictEqual ( state . id , StateID . AppearInit ) ;
412
412
} ) ;
413
413
it ( "should skip to active and complete" , ( ) => {
414
- [ StateID . Default , StateID . DefaultInit , StateID . AppearInit ] . forEach ( ( id ) => {
414
+ [ StateID . Default , StateID . DefaultNew , StateID . AppearNew ] . forEach ( ( id ) => {
415
415
const { state, pending, completed} = reducer ( id , { kind : actionID , props : { } } ) ;
416
416
assert . isUndefined ( pending ) ;
417
417
assert . strictEqual ( state . id , StateID . Active ) ;
418
418
assert . isTrue ( completed ) ;
419
419
} ) ;
420
420
} ) ;
421
421
it ( "should skip to default and complete" , ( ) => {
422
- [ StateID . Active , StateID . ActiveInit ] . forEach ( ( id ) => {
422
+ [ StateID . Active , StateID . ActiveNew ] . forEach ( ( id ) => {
423
423
const { state, pending, completed} = reducer ( id , { kind : actionID , props : { } } ) ;
424
424
assert . isUndefined ( pending ) ;
425
425
assert . strictEqual ( state . id , StateID . Default ) ;
@@ -492,25 +492,25 @@ describe("actions", () => {
492
492
} ) ;
493
493
describe ( "TransitionTrigger" , ( ) => {
494
494
const actionID = ActionID . TransitionTrigger ;
495
- it ( "should transit to enter pending state" , ( ) => {
496
- [ StateID . Default , StateID . DefaultInit ] . forEach ( ( id ) => {
495
+ it ( "should transit to enter init state" , ( ) => {
496
+ [ StateID . Default , StateID . DefaultNew ] . forEach ( ( id ) => {
497
497
const { state, pending} = reducer ( id , { kind : actionID , props : { enterStyle : { } } } ) ;
498
498
assert . strictEqual ( pending , ActionID . TransitionPrepare ) ;
499
- assert . strictEqual ( state . id , StateID . EnterPending ) ;
499
+ assert . strictEqual ( state . id , StateID . EnterInit ) ;
500
500
} ) ;
501
501
} ) ;
502
- it ( "should transit to leave pending state" , ( ) => {
503
- [ StateID . Active , StateID . ActiveInit ] . forEach ( ( id ) => {
502
+ it ( "should transit to leave init state" , ( ) => {
503
+ [ StateID . Active , StateID . ActiveNew ] . forEach ( ( id ) => {
504
504
const { state, pending} = reducer ( id , { kind : actionID , props : { leaveStyle : { } } } ) ;
505
505
assert . strictEqual ( pending , ActionID . TransitionPrepare ) ;
506
- assert . strictEqual ( state . id , StateID . LeavePending ) ;
506
+ assert . strictEqual ( state . id , StateID . LeaveInit ) ;
507
507
} ) ;
508
508
} ) ;
509
- it ( "should transit to appear pending state" , ( ) => {
510
- const id = StateID . AppearInit ;
509
+ it ( "should transit to appear init state" , ( ) => {
510
+ const id = StateID . AppearNew ;
511
511
const { state, pending} = reducer ( id , { kind : actionID , props : { appearStyle : { } } } ) ;
512
512
assert . strictEqual ( pending , ActionID . TransitionPrepare ) ;
513
- assert . strictEqual ( state . id , StateID . AppearPending ) ;
513
+ assert . strictEqual ( state . id , StateID . AppearInit ) ;
514
514
} ) ;
515
515
it ( "should transit to enter triggered state" , ( ) => {
516
516
const id = StateID . EnterPrepare ;
@@ -530,26 +530,26 @@ describe("actions", () => {
530
530
assert . isUndefined ( pending ) ;
531
531
assert . strictEqual ( state . id , StateID . AppearTriggered ) ;
532
532
} ) ;
533
- it ( "should interrupt enter pending and triggered" , ( ) => {
534
- [ StateID . EnterPending , StateID . EnterPrepare , StateID . EnterTriggered ] . forEach ( ( id ) => {
533
+ it ( "should interrupt enter init and triggered" , ( ) => {
534
+ [ StateID . EnterInit , StateID . EnterPrepare , StateID . EnterTriggered ] . forEach ( ( id ) => {
535
535
const props = { active : false } ;
536
536
const { state, pending, completed} = reducer ( id , { kind : actionID , props } ) ;
537
537
assert . isUndefined ( pending ) ;
538
538
assert . strictEqual ( state . id , StateID . Default ) ;
539
539
assert . isTrue ( completed ) ;
540
540
} ) ;
541
541
} ) ;
542
- it ( "should interrupt leave pending and triggered" , ( ) => {
543
- [ StateID . LeavePending , StateID . LeavePrepare , StateID . LeaveTriggered ] . forEach ( ( id ) => {
542
+ it ( "should interrupt leave init and triggered" , ( ) => {
543
+ [ StateID . LeaveInit , StateID . LeavePrepare , StateID . LeaveTriggered ] . forEach ( ( id ) => {
544
544
const props = { active : true } ;
545
545
const { state, pending, completed} = reducer ( id , { kind : actionID , props } ) ;
546
546
assert . isUndefined ( pending ) ;
547
547
assert . strictEqual ( state . id , StateID . Active ) ;
548
548
assert . isTrue ( completed ) ;
549
549
} ) ;
550
550
} ) ;
551
- it ( "should interrupt appear pending and triggered" , ( ) => {
552
- [ StateID . AppearPending , StateID . AppearPrepare , StateID . AppearTriggered ] . forEach ( ( id ) => {
551
+ it ( "should interrupt appear init and triggered" , ( ) => {
552
+ [ StateID . AppearInit , StateID . AppearPrepare , StateID . AppearTriggered ] . forEach ( ( id ) => {
553
553
const props = { active : false } ;
554
554
const { state, pending, completed} = reducer ( id , { kind : actionID , props } ) ;
555
555
assert . isUndefined ( pending ) ;
0 commit comments