@@ -321,6 +321,68 @@ describe('Test axes', function() {
321
321
} ) ;
322
322
} ) ;
323
323
324
+ describe ( 'categorymode' , function ( ) {
325
+
326
+ var gd ;
327
+
328
+ beforeEach ( function ( ) {
329
+ gd = createGraphDiv ( ) ;
330
+ } ) ;
331
+
332
+ afterEach ( destroyGraphDiv ) ;
333
+
334
+ describe ( 'setting, or not setting categorymode if it is not explicitly declared' , function ( ) {
335
+
336
+ it ( 'should set categorymode to default if categorymode and categorylist are not supplied' , function ( ) {
337
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , { xaxis : { type : 'category' } } ) ;
338
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'trace' ) ;
339
+ } ) ;
340
+
341
+ it ( 'should set categorymode to default even if type is not set to category explicitly' , function ( ) {
342
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] ) ;
343
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'trace' ) ;
344
+ } ) ;
345
+
346
+ it ( 'should NOT set categorymode to default if type is not category' , function ( ) {
347
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] ) ;
348
+ expect ( gd . _fullLayout . yaxis . categorymode ) . toBe ( undefined ) ;
349
+ } ) ;
350
+
351
+ it ( 'should set categorymode to default if type is overridden to be category' , function ( ) {
352
+ PlotlyInternal . plot ( gd , [ { x : [ 1 , 2 , 3 , 4 , 5 ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , { yaxis : { type : 'category' } } ) ;
353
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( undefined ) ;
354
+ expect ( gd . _fullLayout . yaxis . categorymode ) . toBe ( 'trace' ) ;
355
+ } ) ;
356
+
357
+ } ) ;
358
+
359
+ describe ( 'setting, or not setting categorymode to "array"' , function ( ) {
360
+
361
+ it ( 'should leave categorymode on "array" if it is supplied' , function ( ) {
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' ] }
364
+ } ) ;
365
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'array' ) ;
366
+ } ) ;
367
+
368
+ it ( 'should switch categorymode on "array" if it is not supplied but categorylist is supplied' , function ( ) {
369
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
370
+ xaxis : { type : 'category' , categorylist : [ 'b' , 'a' , 'd' , 'e' , 'c' ] }
371
+ } ) ;
372
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'array' ) ;
373
+ } ) ;
374
+
375
+ it ( 'should revert categorymode to "trace" if "array" is supplied but there is no list' , function ( ) {
376
+ PlotlyInternal . plot ( gd , [ { x : [ 'c' , 'a' , 'e' , 'b' , 'd' ] , y : [ 15 , 11 , 12 , 13 , 14 ] } ] , {
377
+ xaxis : { type : 'category' , categorymode : "array" }
378
+ } ) ;
379
+ expect ( gd . _fullLayout . xaxis . categorymode ) . toBe ( 'trace' ) ;
380
+ } ) ;
381
+
382
+ } ) ;
383
+
384
+ } ) ;
385
+
324
386
describe ( 'handleTickDefaults' , function ( ) {
325
387
var data = [ { x : [ 1 , 2 , 3 ] , y : [ 3 , 4 , 5 ] } ] ,
326
388
gd ;
0 commit comments