@@ -5,22 +5,6 @@ var createGraphDiv = require('../assets/create_graph_div');
55var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
66var fail = require ( '../assets/fail_test' ) ;
77
8- describe ( 'Plots.evaluateAPICommandBinding' , function ( ) {
9- it ( 'evaluates a data binding' , function ( ) {
10- var gd = { _fullData : [ null , { line : { width : 7 } } ] } ;
11- var astr = 'data[1].line.width' ;
12-
13- expect ( Plots . evaluateAPICommandBinding ( gd , astr ) ) . toEqual ( 7 ) ;
14- } ) ;
15-
16- it ( 'evaluates a layout binding' , function ( ) {
17- var gd = { _fullLayout : { margin : { t : 100 } } } ;
18- var astr = 'layout.margin.t' ;
19-
20- expect ( Plots . evaluateAPICommandBinding ( gd , astr ) ) . toEqual ( 100 ) ;
21- } ) ;
22- } ) ;
23-
248describe ( 'Plots.executeAPICommand' , function ( ) {
259 'use strict' ;
2610
@@ -75,7 +59,7 @@ describe('Plots.executeAPICommand', function() {
7559 } ) ;
7660} ) ;
7761
78- describe ( 'Plots.hasSimpleBindings ' , function ( ) {
62+ describe ( 'Plots.hasSimpleAPICommandBindings ' , function ( ) {
7963 'use strict' ;
8064 var gd ;
8165 beforeEach ( function ( ) {
@@ -91,20 +75,25 @@ describe('Plots.hasSimpleBindings', function() {
9175 destroyGraphDiv ( gd ) ;
9276 } ) ;
9377
94- it ( 'return true when bindings are simple' , function ( ) {
95- var isSimple = Plots . hasSimpleBindings ( gd , [ {
78+ it ( 'return the binding when bindings are simple' , function ( ) {
79+ var isSimple = Plots . hasSimpleAPICommandBindings ( gd , [ {
9680 method : 'restyle' ,
9781 args : [ { 'marker.size' : 10 } ]
9882 } , {
9983 method : 'restyle' ,
10084 args : [ { 'marker.size' : 20 } ]
10185 } ] ) ;
10286
103- expect ( isSimple ) . toBe ( true ) ;
87+ expect ( isSimple ) . toEqual ( {
88+ type : 'data' ,
89+ prop : 'marker.size' ,
90+ traces : null ,
91+ value : 10
92+ } ) ;
10493 } ) ;
10594
10695 it ( 'return false when properties are not the same' , function ( ) {
107- var isSimple = Plots . hasSimpleBindings ( gd , [ {
96+ var isSimple = Plots . hasSimpleAPICommandBindings ( gd , [ {
10897 method : 'restyle' ,
10998 args : [ { 'marker.size' : 10 } ]
11099 } , {
@@ -116,7 +105,7 @@ describe('Plots.hasSimpleBindings', function() {
116105 } ) ;
117106
118107 it ( 'return false when a command binds to more than one property' , function ( ) {
119- var isSimple = Plots . hasSimpleBindings ( gd , [ {
108+ var isSimple = Plots . hasSimpleAPICommandBindings ( gd , [ {
120109 method : 'restyle' ,
121110 args : [ { 'marker.color' : 10 , 'marker.size' : 12 } ]
122111 } , {
@@ -128,7 +117,7 @@ describe('Plots.hasSimpleBindings', function() {
128117 } ) ;
129118
130119 it ( 'return false when commands affect different traces' , function ( ) {
131- var isSimple = Plots . hasSimpleBindings ( gd , [ {
120+ var isSimple = Plots . hasSimpleAPICommandBindings ( gd , [ {
132121 method : 'restyle' ,
133122 args : [ { 'marker.color' : 10 } , [ 0 ] ]
134123 } , {
@@ -139,28 +128,38 @@ describe('Plots.hasSimpleBindings', function() {
139128 expect ( isSimple ) . toBe ( false ) ;
140129 } ) ;
141130
142- it ( 'return true when commands affect the same traces' , function ( ) {
143- var isSimple = Plots . hasSimpleBindings ( gd , [ {
131+ it ( 'return the binding when commands affect the same traces' , function ( ) {
132+ var isSimple = Plots . hasSimpleAPICommandBindings ( gd , [ {
144133 method : 'restyle' ,
145134 args : [ { 'marker.color' : 10 } , [ 1 ] ]
146135 } , {
147136 method : 'restyle' ,
148137 args : [ { 'marker.color' : 20 } , [ 1 ] ]
149138 } ] ) ;
150139
151- expect ( isSimple ) . toBe ( true ) ;
140+ expect ( isSimple ) . toEqual ( {
141+ type : 'data' ,
142+ prop : 'marker.color' ,
143+ traces : [ 1 ] ,
144+ value : [ 10 ]
145+ } ) ;
152146 } ) ;
153147
154- it ( 'return true when commands affect the same traces in different order' , function ( ) {
155- var isSimple = Plots . hasSimpleBindings ( gd , [ {
148+ it ( 'return the binding when commands affect the same traces in different order' , function ( ) {
149+ var isSimple = Plots . hasSimpleAPICommandBindings ( gd , [ {
156150 method : 'restyle' ,
157151 args : [ { 'marker.color' : 10 } , [ 1 , 2 ] ]
158152 } , {
159153 method : 'restyle' ,
160154 args : [ { 'marker.color' : 20 } , [ 2 , 1 ] ]
161155 } ] ) ;
162156
163- expect ( isSimple ) . toBe ( true ) ;
157+ expect ( isSimple ) . toEqual ( {
158+ type : 'data' ,
159+ prop : 'marker.color' ,
160+ traces : [ 1 , 2 ] ,
161+ value : [ 10 , 10 ]
162+ } ) ;
164163 } ) ;
165164} ) ;
166165
0 commit comments