@@ -399,22 +399,27 @@ describe('Test axes', function() {
399
399
it ( 'should set categoryorder to default if categoryorder and categoryarray are not supplied' , function ( ) {
400
400
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , { xaxis : { type : 'category' } } ) ;
401
401
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'trace' ) ;
402
+ expect ( gd . _fullLayout . xaxis . categorarray ) . toBe ( undefined ) ;
402
403
} ) ;
403
404
404
405
it ( 'should set categoryorder to default even if type is not set to category explicitly' , function ( ) {
405
406
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] ) ;
406
407
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'trace' ) ;
408
+ expect ( gd . _fullLayout . xaxis . categorarray ) . toBe ( undefined ) ;
407
409
} ) ;
408
410
409
411
it ( 'should NOT set categoryorder to default if type is not category' , function ( ) {
410
412
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] ) ;
411
413
expect ( gd . _fullLayout . yaxis . categoryorder ) . toBe ( undefined ) ;
414
+ expect ( gd . _fullLayout . xaxis . categorarray ) . toBe ( undefined ) ;
412
415
} ) ;
413
416
414
417
it ( 'should set categoryorder to default if type is overridden to be category' , function ( ) {
415
418
PlotlyInternal . plot ( gd , [ { x : [ 1 , 2 , 3 , 4 , 5 ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , { yaxis : { type : 'category' } } ) ;
416
419
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( undefined ) ;
420
+ expect ( gd . _fullLayout . yaxis . categorarray ) . toBe ( undefined ) ;
417
421
expect ( gd . _fullLayout . yaxis . categoryorder ) . toBe ( 'trace' ) ;
422
+ expect ( gd . _fullLayout . yaxis . categorarray ) . toBe ( undefined ) ;
418
423
} ) ;
419
424
420
425
} ) ;
@@ -426,20 +431,23 @@ describe('Test axes', function() {
426
431
xaxis : { type : 'category' , categoryorder : 'array' , categoryarray : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
427
432
} ) ;
428
433
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'array' ) ;
434
+ expect ( gd . _fullLayout . xaxis . categoryarray ) . toEqual ( [ 'b' , 'a' , 'd' , 'e' , 'c' ] ) ;
429
435
} ) ;
430
436
431
437
it ( 'should switch categoryorder on "array" if it is not supplied but categoryarray is supplied' , function ( ) {
432
438
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
433
439
xaxis : { type : 'category' , categoryarray : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
434
440
} ) ;
435
441
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'array' ) ;
442
+ expect ( gd . _fullLayout . xaxis . categoryarray ) . toEqual ( [ 'b' , 'a' , 'd' , 'e' , 'c' ] ) ;
436
443
} ) ;
437
444
438
445
it ( 'should revert categoryorder to "trace" if "array" is supplied but there is no list' , function ( ) {
439
446
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
440
447
xaxis : { type : 'category' , categoryorder : 'array' }
441
448
} ) ;
442
449
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'trace' ) ;
450
+ expect ( gd . _fullLayout . xaxis . categorarray ) . toBe ( undefined ) ;
443
451
} ) ;
444
452
445
453
} ) ;
@@ -451,13 +459,15 @@ describe('Test axes', function() {
451
459
xaxis : { type : 'category' , categoryorder : 'array' , categoryarray : [ ] }
452
460
} ) ;
453
461
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'trace' ) ;
462
+ expect ( gd . _fullLayout . xaxis . categoryarray ) . toEqual ( [ ] ) ;
454
463
} ) ;
455
464
456
465
it ( 'should not switch categoryorder on "array" if categoryarray is supplied but empty' , function ( ) {
457
466
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
458
467
xaxis : { type : 'category' , categoryarray : [ ] }
459
468
} ) ;
460
469
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'trace' ) ;
470
+ expect ( gd . _fullLayout . xaxis . categoryarray ) . toEqual ( undefined ) ;
461
471
} ) ;
462
472
} ) ;
463
473
@@ -468,20 +478,23 @@ describe('Test axes', function() {
468
478
xaxis : { type : 'category' , categoryorder : 'trace' , categoryarray : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
469
479
} ) ;
470
480
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'trace' ) ;
481
+ expect ( gd . _fullLayout . xaxis . categoryarray ) . toBe ( undefined ) ;
471
482
} ) ;
472
483
473
484
it ( 'should use specified categoryorder if it is supplied even if categoryarray exists' , function ( ) {
474
485
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
475
486
xaxis : { type : 'category' , categoryorder : 'category ascending' , categoryarray : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
476
487
} ) ;
477
488
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'category ascending' ) ;
489
+ expect ( gd . _fullLayout . xaxis . categoryarray ) . toBe ( undefined ) ;
478
490
} ) ;
479
491
480
492
it ( 'should use specified categoryorder if it is supplied even if categoryarray exists' , function ( ) {
481
493
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
482
494
xaxis : { type : 'category' , categoryorder : 'category descending' , categoryarray : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
483
495
} ) ;
484
496
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'category descending' ) ;
497
+ expect ( gd . _fullLayout . xaxis . categoryarray ) . toBe ( undefined ) ;
485
498
} ) ;
486
499
487
500
} ) ;
@@ -493,13 +506,15 @@ describe('Test axes', function() {
493
506
xaxis : { type : 'category' , categoryorder : 'invalid value' }
494
507
} ) ;
495
508
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'trace' ) ;
509
+ expect ( gd . _fullLayout . xaxis . categoryarray ) . toBe ( undefined ) ;
496
510
} ) ;
497
511
498
512
it ( 'should switch categoryorder to "array" if mode is supplied but invalid and list is supplied' , function ( ) {
499
513
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
500
514
xaxis : { type : 'category' , categoryorder : 'invalid value' , categoryarray : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
501
515
} ) ;
502
516
expect ( gd . _fullLayout . xaxis . categoryorder ) . toBe ( 'array' ) ;
517
+ expect ( gd . _fullLayout . xaxis . categoryarray ) . toEqual ( [ 'b' , 'a' , 'd' , 'e' , 'c' ] ) ;
503
518
} ) ;
504
519
505
520
} ) ;
0 commit comments