@@ -8,11 +8,57 @@ var failTest = require('../assets/fail_test');
88var click = require ( '../assets/click' ) ;
99var getClientPosition = require ( '../assets/get_client_position' ) ;
1010var mouseEvent = require ( '../assets/mouse_event' ) ;
11+ var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
1112
1213var customAssertions = require ( '../assets/custom_assertions' ) ;
1314var assertHoverLabelStyle = customAssertions . assertHoverLabelStyle ;
1415var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
1516
17+
18+ describe ( 'Pie defaults' , function ( ) {
19+ function _supply ( trace ) {
20+ var gd = {
21+ data : [ trace ] ,
22+ layout : { }
23+ } ;
24+
25+ supplyAllDefaults ( gd ) ;
26+
27+ return gd . _fullData [ 0 ] ;
28+ }
29+
30+ it ( 'finds the minimum length of labels & values' , function ( ) {
31+ var out = _supply ( { type : 'pie' , labels : [ 'A' , 'B' ] , values : [ 1 , 2 , 3 ] } ) ;
32+ expect ( out . _length ) . toBe ( 2 ) ;
33+
34+ out = _supply ( { type : 'pie' , labels : [ 'A' , 'B' , 'C' ] , values : [ 1 , 2 ] } ) ;
35+ expect ( out . _length ) . toBe ( 2 ) ;
36+ } ) ;
37+
38+ it ( 'allows labels or values to be missing but not both' , function ( ) {
39+ var out = _supply ( { type : 'pie' , values : [ 1 , 2 ] } ) ;
40+ expect ( out . visible ) . toBe ( true ) ;
41+ expect ( out . _length ) . toBe ( 2 ) ;
42+ expect ( out . label0 ) . toBe ( 0 ) ;
43+ expect ( out . dlabel ) . toBe ( 1 ) ;
44+
45+ out = _supply ( { type : 'pie' , labels : [ 'A' , 'B' ] } ) ;
46+ expect ( out . visible ) . toBe ( true ) ;
47+ expect ( out . _length ) . toBe ( 2 ) ;
48+
49+ out = _supply ( { type : 'pie' } ) ;
50+ expect ( out . visible ) . toBe ( false ) ;
51+ } ) ;
52+
53+ it ( 'is marked invisible if either labels or values is empty' , function ( ) {
54+ var out = _supply ( { type : 'pie' , labels : [ ] , values : [ 1 , 2 ] } ) ;
55+ expect ( out . visible ) . toBe ( false ) ;
56+
57+ out = _supply ( { type : 'pie' , labels : [ 'A' , 'B' ] , values : [ ] } ) ;
58+ expect ( out . visible ) . toBe ( false ) ;
59+ } ) ;
60+ } ) ;
61+
1662describe ( 'Pie traces:' , function ( ) {
1763 'use strict' ;
1864
0 commit comments