@@ -271,14 +271,8 @@ describe('groupby', function() {
271271 expect ( gd . data [ 0 ] . x ) . toEqual ( [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ) ;
272272 expect ( gd . data [ 0 ] . y ) . toEqual ( [ 1 , 2 , 3 , 1 , 2 , 3 , 1 ] ) ;
273273
274- expect ( gd . _fullData . length ) . toEqual ( 0 ) ; // fixme: it passes with 0; shouldn't it be 1? (one implied group)
275-
276- /* since the array is of zero length, the below items are obv. meaningless to test
277- expect(gd._fullData[0].x).toEqual([1, -1, -2, 0, 1, 2, 3]);
278- expect(gd._fullData[0].y).toEqual([1, 2, 3, 1, 2, 3, 1]);
279- */
280-
281- assertDims ( [ ] ) ; // fixme: same thing, looks like zero dimensionality
274+ expect ( gd . _fullData . length ) . toEqual ( 1 ) ;
275+ assertDims ( [ 7 ] ) ;
282276
283277 done ( ) ;
284278 } ) ;
@@ -493,19 +487,6 @@ describe('groupby', function() {
493487 } ]
494488 } ] ;
495489
496- var mockData6 = [ {
497- mode : 'markers+lines' ,
498- ids : [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ,
499- x : [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ,
500- y : [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ,
501- marker : { line : { width : [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] } } ,
502- transforms : [ {
503- type : 'groupby' ,
504- groups : [ 'a' , 'a' , 'b' , 'a' , 'b' , 'b' , 'a' ] ,
505- style : { a : { marker : { color : 'red' } } , b : { marker : { color : 'blue' } } }
506- } ]
507- } ] ;
508-
509490 it ( '`data` preserves user supplied input but `gd._fullData` reflects the grouping' , test ( mockData1 ) ) ;
510491
511492 it ( 'passes with lots of attributes and heterogenous attrib presence' , test ( mockData2 ) ) ;
@@ -525,16 +506,43 @@ describe('groupby', function() {
525506
526507 it ( 'passes with no explicit styling in the group transform at all' , test ( mockData5 ) ) ;
527508
528- it ( 'passes with no explicit styling in the group transform at all' , test ( mockData6 ) ) ;
529-
530509 } ) ;
531510
532511 describe ( 'passes with no `groups`' , function ( ) {
533512 'use strict' ;
534513
535- // afterEach(destroyGraphDiv);
514+ afterEach ( destroyGraphDiv ) ;
536515
537- var mockData = [ {
516+ function test ( mockData ) {
517+
518+ return function ( done ) {
519+ var data = Lib . extendDeep ( [ ] , mockData ) ;
520+
521+ var gd = createGraphDiv ( ) ;
522+
523+ Plotly . plot ( gd , data ) . then ( function ( ) {
524+
525+ expect ( gd . data . length ) . toEqual ( 1 ) ;
526+ expect ( gd . data [ 0 ] . ids ) . toEqual ( [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ) ;
527+ expect ( gd . data [ 0 ] . x ) . toEqual ( [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ) ;
528+ expect ( gd . data [ 0 ] . y ) . toEqual ( [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ) ;
529+ expect ( gd . data [ 0 ] . marker . line . width ) . toEqual ( [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] ) ;
530+
531+ expect ( gd . _fullData . length ) . toEqual ( 1 ) ;
532+
533+ expect ( gd . _fullData [ 0 ] . ids ) . toEqual ( [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ) ;
534+ expect ( gd . _fullData [ 0 ] . x ) . toEqual ( [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ) ;
535+ expect ( gd . _fullData [ 0 ] . y ) . toEqual ( [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ) ;
536+ expect ( gd . _fullData [ 0 ] . marker . line . width ) . toEqual ( [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] ) ;
537+
538+ assertDims ( [ 7 ] ) ;
539+
540+ done ( ) ;
541+ } ) ;
542+ } ;
543+ }
544+
545+ var mockData0 = [ {
538546 mode : 'markers+lines' ,
539547 ids : [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ,
540548 x : [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ,
@@ -547,38 +555,35 @@ describe('groupby', function() {
547555 } ]
548556 } ] ;
549557
550- fit ( 'passes' , function ( done ) {
551- var data = Lib . extendDeep ( [ ] , mockData ) ;
552-
553- var gd = createGraphDiv ( ) ;
554-
555- Plotly . plot ( gd , data ) . then ( function ( ) {
556-
557- /*
558- expect(gd.data.length).toEqual(1);
559- expect(gd.data[0].ids).toEqual(['q', 'w', 'r', 't', 'y', 'u', 'i']);
560- expect(gd.data[0].x).toEqual([1, -1, -2, 0, 1, 2, 3]);
561- expect(gd.data[0].y).toEqual([0, 1, 2, 3, 5, 4, 6]);
562- expect(gd.data[0].marker.line.width).toEqual([4, 2, 4, 2, 2, 3, 3]);
563-
564- expect(gd._fullData.length).toEqual(2);
565-
566- expect(gd._fullData[0].ids).toEqual(['q', 'w', 't', 'i']);
567- expect(gd._fullData[0].x).toEqual([1, -1, 0, 3]);
568- expect(gd._fullData[0].y).toEqual([0, 1, 3, 6]);
569- expect(gd._fullData[0].marker.line.width).toEqual([4, 2, 2, 3]);
570-
571- expect(gd._fullData[1].ids).toEqual(['r', 'y', 'u']);
572- expect(gd._fullData[1].x).toEqual([-2, 1, 2]);
573- expect(gd._fullData[1].y).toEqual([2, 5, 4]);
574- expect(gd._fullData[1].marker.line.width).toEqual([4, 2, 3]);
558+ var mockData1 = [ {
559+ mode : 'markers+lines' ,
560+ ids : [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ,
561+ x : [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ,
562+ y : [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ,
563+ marker : { size : 20 , line : { width : [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] } } ,
564+ transforms : [ {
565+ type : 'groupby' ,
566+ groups : [ ] ,
567+ style : { a : { marker : { color : 'red' } } , b : { marker : { color : 'blue' } } }
568+ } ]
569+ } ] ;
575570
576- assertDims([4, 3]);
577- */
571+ var mockData2 = [ {
572+ mode : 'markers+lines' ,
573+ ids : [ 'q' , 'w' , 'r' , 't' , 'y' , 'u' , 'i' ] ,
574+ x : [ 1 , - 1 , - 2 , 0 , 1 , 2 , 3 ] ,
575+ y : [ 0 , 1 , 2 , 3 , 5 , 4 , 6 ] ,
576+ marker : { size : 20 , line : { width : [ 4 , 2 , 4 , 2 , 2 , 3 , 3 ] } } ,
577+ transforms : [ {
578+ type : 'groupby' ,
579+ groups : null ,
580+ style : { a : { marker : { color : 'red' } } , b : { marker : { color : 'blue' } } }
581+ } ]
582+ } ] ;
578583
579- done ( ) ;
580- } ) ;
581- } ) ;
584+ it ( 'passes with no groups' , test ( mockData0 ) ) ;
585+ it ( 'passes with empty groups' , test ( mockData1 ) ) ;
586+ it ( 'passes with falsey groups' , test ( mockData2 ) ) ;
582587
583588 } ) ;
584589} ) ;
0 commit comments