@@ -356,15 +356,15 @@ describe('Test axes', function() {
356
356
357
357
} ) ;
358
358
359
- describe ( 'setting, or not setting categorymode to "array"' , function ( ) {
359
+ describe ( 'setting categorymode to "array"' , function ( ) {
360
360
361
361
it ( 'should leave categorymode on "array" if it is supplied' , function ( ) {
362
362
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
363
- xaxis : { type : 'category' , categorymode : " array" , categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
363
+ xaxis : { type : 'category' , categorymode : ' array' , categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
364
364
} ) ;
365
365
expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'array' ) ;
366
366
} ) ;
367
-
367
+
368
368
it ( 'should switch categorymode on "array" if it is not supplied but categorylist is supplied' , function ( ) {
369
369
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
370
370
xaxis : { type : 'category' , categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
@@ -374,11 +374,71 @@ describe('Test axes', function() {
374
374
375
375
it ( 'should revert categorymode to "trace" if "array" is supplied but there is no list' , function ( ) {
376
376
PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
377
- xaxis : { type : 'category' , categorymode : "array" }
377
+ xaxis : { type : 'category' , categorymode : 'array' }
378
+ } ) ;
379
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'trace' ) ;
380
+ } ) ;
381
+
382
+ } ) ;
383
+
384
+ describe ( 'do not set categorymode to "array" if list exists but empty' , function ( ) {
385
+
386
+ it ( 'should switch categorymode to default if list is not supplied' , function ( ) {
387
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
388
+ xaxis : { type : 'category' , categorymode : 'array' , categorylist : [ ] }
389
+ } ) ;
390
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'trace' ) ;
391
+ } ) ;
392
+
393
+ it ( 'should not switch categorymode on "array" if categorylist is supplied but empty' , function ( ) {
394
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
395
+ xaxis : { type : 'category' , categorylist : [ ] }
396
+ } ) ;
397
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'trace' ) ;
398
+ } ) ;
399
+ } ) ;
400
+
401
+ describe ( 'do NOT set categorymode to "array" if it has some other proper value' , function ( ) {
402
+
403
+ it ( 'should use specified categorymode if it is supplied even if categorylist exists' , function ( ) {
404
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
405
+ xaxis : { type : 'category' , categorymode : 'trace' , categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
378
406
} ) ;
379
407
expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'trace' ) ;
380
408
} ) ;
381
409
410
+ it ( 'should use specified categorymode if it is supplied even if categorylist exists' , function ( ) {
411
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
412
+ xaxis : { type : 'category' , categorymode : 'category ascending' , categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
413
+ } ) ;
414
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'category ascending' ) ;
415
+ } ) ;
416
+
417
+ it ( 'should use specified categorymode if it is supplied even if categorylist exists' , function ( ) {
418
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
419
+ xaxis : { type : 'category' , categorymode : 'category descending' , categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
420
+ } ) ;
421
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'category descending' ) ;
422
+ } ) ;
423
+
424
+ } ) ;
425
+
426
+ describe ( 'setting categorymode to the default if the value is unexpected' , function ( ) {
427
+
428
+ it ( 'should switch categorymode to "trace" if mode is supplied but invalid' , function ( ) {
429
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
430
+ xaxis : { type : 'category' , categorymode : 'invalid value' }
431
+ } ) ;
432
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'trace' ) ;
433
+ } ) ;
434
+
435
+ it ( 'should switch categorymode to "array" if mode is supplied but invalid and list is supplied' , function ( ) {
436
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
437
+ xaxis : { type : 'category' , categorymode : 'invalid value' , categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
438
+ } ) ;
439
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'array' ) ;
440
+ } ) ;
441
+
382
442
} ) ;
383
443
384
444
} ) ;
0 commit comments