@@ -8,11 +8,57 @@ var failTest = require('../assets/fail_test');
8
8
var click = require ( '../assets/click' ) ;
9
9
var getClientPosition = require ( '../assets/get_client_position' ) ;
10
10
var mouseEvent = require ( '../assets/mouse_event' ) ;
11
+ var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
11
12
12
13
var customAssertions = require ( '../assets/custom_assertions' ) ;
13
14
var assertHoverLabelStyle = customAssertions . assertHoverLabelStyle ;
14
15
var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
15
16
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
+
16
62
describe ( 'Pie traces:' , function ( ) {
17
63
'use strict' ;
18
64
0 commit comments