@@ -23,7 +23,7 @@ describe('Plots.executeAPICommand', function() {
23
23
beforeEach ( function ( ) {
24
24
spyOn ( PlotlyInternal , 'restyle' ) . and . callFake ( function ( ) {
25
25
return Promise . resolve ( 'resolution' ) ;
26
- } )
26
+ } ) ;
27
27
} ) ;
28
28
29
29
it ( 'calls the API method and resolves' , function ( done ) {
@@ -43,7 +43,7 @@ describe('Plots.executeAPICommand', function() {
43
43
beforeEach ( function ( ) {
44
44
spyOn ( PlotlyInternal , 'restyle' ) . and . callFake ( function ( ) {
45
45
return Promise . reject ( 'rejection' ) ;
46
- } )
46
+ } ) ;
47
47
} ) ;
48
48
49
49
it ( 'calls the API method and rejects' , function ( done ) {
@@ -68,7 +68,10 @@ describe('Plots.computeAPICommandBindings', function() {
68
68
beforeEach ( function ( ) {
69
69
gd = createGraphDiv ( ) ;
70
70
71
- Plotly . plot ( gd , [ { x : [ 1 , 2 , 3 ] , y : [ 4 , 5 , 6 ] } ] ) ;
71
+ Plotly . plot ( gd , [
72
+ { x : [ 1 , 2 , 3 ] , y : [ 1 , 2 , 3 ] } ,
73
+ { x : [ 1 , 2 , 3 ] , y : [ 4 , 5 , 6 ] } ,
74
+ ] ) ;
72
75
} ) ;
73
76
74
77
afterEach ( function ( ) {
@@ -77,10 +80,102 @@ describe('Plots.computeAPICommandBindings', function() {
77
80
78
81
describe ( 'restyle' , function ( ) {
79
82
describe ( 'astr + val notation' , function ( ) {
80
- it ( 'computes the binding' , function ( ) {
81
- var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ 'marker.size' , 7 ] ) ;
83
+ describe ( 'with a single attribute' , function ( ) {
84
+ it ( 'with a scalar value' , function ( ) {
85
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ 'marker.size' , 7 ] ) ;
86
+ expect ( result ) . toEqual ( [ 'data[0].marker.size' , 'data[1].marker.size' ] ) ;
87
+ } ) ;
88
+
89
+ it ( 'with an array value and no trace specified' , function ( ) {
90
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ 'marker.size' , [ 7 ] ] ) ;
91
+ expect ( result ) . toEqual ( [ 'data[0].marker.size' , 'data[1].marker.size' ] ) ;
92
+ } ) ;
93
+
94
+ it ( 'with trace specified' , function ( ) {
95
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ 'marker.size' , 7 , [ 0 ] ] ) ;
96
+ expect ( result ) . toEqual ( [ 'data[0].marker.size' ] ) ;
97
+ } ) ;
98
+
99
+ it ( 'with a different trace specified' , function ( ) {
100
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ 'marker.size' , 7 , [ 1 ] ] ) ;
101
+ expect ( result ) . toEqual ( [ 'data[1].marker.size' ] ) ;
102
+ } ) ;
103
+
104
+ it ( 'with an array value' , function ( ) {
105
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ 'marker.size' , [ 7 ] , [ 0 ] ] ) ;
106
+ expect ( result ) . toEqual ( [ 'data[1].marker.size' ] ) ;
107
+ } ) ;
108
+
109
+ it ( 'with two array values and two traces specified' , function ( ) {
110
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ 'marker.size' , [ 7 , 5 ] , [ 0 , 1 ] ] ) ;
111
+ expect ( result ) . toEqual ( [ 'data[0].marker.size' , 'data[1].marker.size' ] ) ;
112
+ } ) ;
113
+
114
+ it ( 'with traces specified in reverse order' , function ( ) {
115
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ 'marker.size' , [ 7 , 5 ] , [ 1 , 0 ] ] ) ;
116
+ expect ( result ) . toEqual ( [ 'data[1].marker.size' , 'data[0].marker.size' ] ) ;
117
+ } ) ;
118
+
119
+ it ( 'with two values and a single trace specified' , function ( ) {
120
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ 'marker.size' , [ 7 , 5 ] , [ 0 ] ] ) ;
121
+ expect ( result ) . toEqual ( [ 'data[0].marker.size' ] ) ;
122
+ } ) ;
123
+
124
+ it ( 'with two values and a different trace specified' , function ( ) {
125
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ 'marker.size' , [ 7 , 5 ] , [ 1 ] ] ) ;
126
+ expect ( result ) . toEqual ( [ 'data[1].marker.size' ] ) ;
127
+ } ) ;
128
+ } ) ;
129
+ } ) ;
130
+
131
+ describe ( 'aobj notation' , function ( ) {
132
+ describe ( 'with a single attribute' , function ( ) {
133
+ it ( 'with a scalar value' , function ( ) {
134
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ { 'marker.size' : 7 } ] ) ;
135
+ expect ( result ) . toEqual ( [ 'data[0].marker.size' , 'data[1].marker.size' ] ) ;
136
+ } ) ;
137
+
138
+ it ( 'with trace specified' , function ( ) {
139
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ { 'marker.size' : 7 } , [ 0 ] ] ) ;
140
+ expect ( result ) . toEqual ( [ 'data[0].marker.size' ] ) ;
141
+ } ) ;
142
+
143
+ it ( 'with a different trace specified' , function ( ) {
144
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ { 'marker.size' : 7 } , [ 1 ] ] ) ;
145
+ expect ( result ) . toEqual ( [ 'data[1].marker.size' ] ) ;
146
+ } ) ;
147
+
148
+ it ( 'with an array value' , function ( ) {
149
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ { 'marker.size' : [ 7 ] } , [ 0 ] ] ) ;
150
+ expect ( result ) . toEqual ( [ 'data[1].marker.size' ] ) ;
151
+ } ) ;
152
+
153
+ it ( 'with two array values and two traces specified' , function ( ) {
154
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ { 'marker.size' : [ 7 , 5 ] } , [ 0 , 1 ] ] ) ;
155
+ expect ( result ) . toEqual ( [ 'data[0].marker.size' , 'data[1].marker.size' ] ) ;
156
+ } ) ;
157
+
158
+ it ( 'with traces specified in reverse order' , function ( ) {
159
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ { 'marker.size' : [ 7 , 5 ] } , [ 1 , 0 ] ] ) ;
160
+ expect ( result ) . toEqual ( [ 'data[1].marker.size' , 'data[0].marker.size' ] ) ;
161
+ } ) ;
162
+
163
+ it ( 'with two values and a single trace specified' , function ( ) {
164
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ { 'marker.size' : [ 7 , 5 ] } , [ 0 ] ] ) ;
165
+ expect ( result ) . toEqual ( [ 'data[0].marker.size' ] ) ;
166
+ } ) ;
167
+
168
+ it ( 'with two values and a different trace specified' , function ( ) {
169
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ { 'marker.size' : [ 7 , 5 ] } , [ 1 ] ] ) ;
170
+ expect ( result ) . toEqual ( [ 'data[1].marker.size' ] ) ;
171
+ } ) ;
172
+ } ) ;
82
173
83
- expect ( result ) . toEqual ( [ 'data[0].marker.size' ] ) ;
174
+ describe ( 'with multiple attributes' , function ( ) {
175
+ it ( 'with a scalar value' , function ( ) {
176
+ var result = Plots . computeAPICommandBindings ( gd , 'restyle' , [ { 'marker.size' : 7 , 'text.color' : 'blue' } ] ) ;
177
+ expect ( result ) . toEqual ( [ 'data[0].marker.size' , 'data[1].marker.size' , 'data[0].text.color' , 'data[1].text.color' ] ) ;
178
+ } ) ;
84
179
} ) ;
85
180
} ) ;
86
181
} ) ;
0 commit comments