1
- var Plotly = require ( '@src/plotly' ) ;
1
+ var Plotly = require ( '@src' ) ;
2
+ var PlotlyInternal = require ( '@src/plotly' ) ;
2
3
var Plots = require ( '@src/plots/plots' ) ;
4
+ var Lib = require ( '@src/lib' ) ;
3
5
var Scatter = require ( '@src/traces/scatter' ) ;
4
6
var Bar = require ( '@src/traces/bar' ) ;
5
7
var Legend = require ( '@src/components/legend' ) ;
6
8
7
- describe ( 'Test graph_obj' , function ( ) {
9
+
10
+ describe ( 'Test plot api' , function ( ) {
8
11
'use strict' ;
9
12
10
13
describe ( 'Plotly.restyle' , function ( ) {
@@ -67,7 +70,7 @@ describe('Test graph_obj', function() {
67
70
{ 'name' : 'd' }
68
71
]
69
72
} ;
70
- spyOn ( Plotly , 'redraw' ) ;
73
+ spyOn ( PlotlyInternal , 'redraw' ) ;
71
74
} ) ;
72
75
73
76
it ( 'should throw an error when indices are omitted' , function ( ) {
@@ -103,7 +106,7 @@ describe('Test graph_obj', function() {
103
106
104
107
Plotly . deleteTraces ( gd , - 1 ) ;
105
108
expect ( gd . data ) . toEqual ( expectedData ) ;
106
- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
109
+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
107
110
108
111
} ) ;
109
112
@@ -115,7 +118,7 @@ describe('Test graph_obj', function() {
115
118
116
119
Plotly . deleteTraces ( gd , [ 0 , 3 ] ) ;
117
120
expect ( gd . data ) . toEqual ( expectedData ) ;
118
- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
121
+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
119
122
120
123
} ) ;
121
124
@@ -127,7 +130,7 @@ describe('Test graph_obj', function() {
127
130
128
131
Plotly . deleteTraces ( gd , [ 3 , 0 ] ) ;
129
132
expect ( gd . data ) . toEqual ( expectedData ) ;
130
- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
133
+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
131
134
132
135
} ) ;
133
136
@@ -138,8 +141,8 @@ describe('Test graph_obj', function() {
138
141
139
142
beforeEach ( function ( ) {
140
143
gd = { data : [ { 'name' : 'a' } , { 'name' : 'b' } ] } ;
141
- spyOn ( Plotly , 'redraw' ) ;
142
- spyOn ( Plotly , 'moveTraces' ) ;
144
+ spyOn ( PlotlyInternal , 'redraw' ) ;
145
+ spyOn ( PlotlyInternal , 'moveTraces' ) ;
143
146
} ) ;
144
147
145
148
it ( 'should throw an error when traces is not an object or an array of objects' , function ( ) {
@@ -186,8 +189,8 @@ describe('Test graph_obj', function() {
186
189
expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
187
190
expect ( gd . data [ 3 ] . name ) . toBeDefined ( ) ;
188
191
expect ( gd . data [ 3 ] . uid ) . toBeDefined ( ) ;
189
- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
190
- expect ( Plotly . moveTraces ) . not . toHaveBeenCalled ( ) ;
192
+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
193
+ expect ( PlotlyInternal . moveTraces ) . not . toHaveBeenCalled ( ) ;
191
194
} ) ;
192
195
193
196
it ( 'should work when newIndices is defined' , function ( ) {
@@ -196,8 +199,8 @@ describe('Test graph_obj', function() {
196
199
expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
197
200
expect ( gd . data [ 3 ] . name ) . toBeDefined ( ) ;
198
201
expect ( gd . data [ 3 ] . uid ) . toBeDefined ( ) ;
199
- expect ( Plotly . redraw ) . not . toHaveBeenCalled ( ) ;
200
- expect ( Plotly . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 2 , - 1 ] , [ 1 , 3 ] ) ;
202
+ expect ( PlotlyInternal . redraw ) . not . toHaveBeenCalled ( ) ;
203
+ expect ( PlotlyInternal . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 2 , - 1 ] , [ 1 , 3 ] ) ;
201
204
202
205
} ) ;
203
206
@@ -207,17 +210,17 @@ describe('Test graph_obj', function() {
207
210
expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
208
211
expect ( gd . data [ 3 ] . name ) . toBeDefined ( ) ;
209
212
expect ( gd . data [ 3 ] . uid ) . toBeDefined ( ) ;
210
- expect ( Plotly . redraw ) . not . toHaveBeenCalled ( ) ;
211
- expect ( Plotly . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 2 , - 1 ] , [ - 3 , - 1 ] ) ;
213
+ expect ( PlotlyInternal . redraw ) . not . toHaveBeenCalled ( ) ;
214
+ expect ( PlotlyInternal . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 2 , - 1 ] , [ - 3 , - 1 ] ) ;
212
215
213
216
} ) ;
214
217
215
218
it ( 'should work when newIndices is an integer' , function ( ) {
216
219
Plotly . addTraces ( gd , { 'name' : 'c' } , 0 ) ;
217
220
expect ( gd . data [ 2 ] . name ) . toBeDefined ( ) ;
218
221
expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
219
- expect ( Plotly . redraw ) . not . toHaveBeenCalled ( ) ;
220
- expect ( Plotly . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 1 ] , [ 0 ] ) ;
222
+ expect ( PlotlyInternal . redraw ) . not . toHaveBeenCalled ( ) ;
223
+ expect ( PlotlyInternal . moveTraces ) . toHaveBeenCalledWith ( gd , [ - 1 ] , [ 0 ] ) ;
221
224
222
225
} ) ;
223
226
} ) ;
@@ -233,7 +236,7 @@ describe('Test graph_obj', function() {
233
236
{ 'name' : 'd' }
234
237
]
235
238
} ;
236
- spyOn ( Plotly , 'redraw' ) ;
239
+ spyOn ( PlotlyInternal , 'redraw' ) ;
237
240
} ) ;
238
241
239
242
it ( 'throw an error when index arrays are unequal' , function ( ) {
@@ -301,7 +304,7 @@ describe('Test graph_obj', function() {
301
304
302
305
Plotly . moveTraces ( gd , 0 , 1 ) ;
303
306
expect ( gd . data ) . toEqual ( expectedData ) ;
304
- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
307
+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
305
308
306
309
} ) ;
307
310
@@ -315,7 +318,7 @@ describe('Test graph_obj', function() {
315
318
316
319
Plotly . moveTraces ( gd , [ 3 , 1 ] , [ 0 , 3 ] ) ;
317
320
expect ( gd . data ) . toEqual ( expectedData ) ;
318
- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
321
+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
319
322
320
323
} ) ;
321
324
@@ -329,7 +332,7 @@ describe('Test graph_obj', function() {
329
332
330
333
Plotly . moveTraces ( gd , [ 3 , 0 ] ) ;
331
334
expect ( gd . data ) . toEqual ( expectedData ) ;
332
- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
335
+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
333
336
334
337
} ) ;
335
338
@@ -343,7 +346,7 @@ describe('Test graph_obj', function() {
343
346
344
347
Plotly . moveTraces ( gd , 1 , - 2 ) ;
345
348
expect ( gd . data ) . toEqual ( expectedData ) ;
346
- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
349
+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
347
350
348
351
} ) ;
349
352
} ) ;
@@ -367,7 +370,7 @@ describe('Test graph_obj', function() {
367
370
} ;
368
371
}
369
372
370
- spyOn ( Plotly , 'redraw' ) ;
373
+ spyOn ( PlotlyInternal , 'redraw' ) ;
371
374
spyOn ( Plotly . Queue , 'add' ) ;
372
375
} ) ;
373
376
@@ -470,7 +473,7 @@ describe('Test graph_obj', function() {
470
473
{ x : [ 1 , 2 , 3 , 4 , 5 ] , marker : { size : [ 2 , 3 , 4 , 5 , 6 ] } }
471
474
] ) ;
472
475
473
- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
476
+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
474
477
} ) ;
475
478
476
479
it ( 'should extend and window traces with update keys' , function ( ) {
@@ -523,11 +526,11 @@ describe('Test graph_obj', function() {
523
526
{ x : [ ] , marker : { size : [ ] } }
524
527
] ) ;
525
528
526
- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
529
+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
527
530
} ) ;
528
531
529
532
it ( 'prepend is the inverse of extend - no maxPoints' , function ( ) {
530
- var cachedData = Plotly . Lib . extendDeep ( [ ] , gd . data ) ;
533
+ var cachedData = Lib . extendDeep ( [ ] , gd . data ) ;
531
534
532
535
Plotly . extendTraces ( gd , {
533
536
x : [ [ 3 , 4 ] , [ 4 , 5 ] ] , 'marker.size' : [ [ 0 , - 1 ] , [ 5 , 6 ] ]
@@ -545,7 +548,7 @@ describe('Test graph_obj', function() {
545
548
546
549
547
550
it ( 'extend is the inverse of prepend - no maxPoints' , function ( ) {
548
- var cachedData = Plotly . Lib . extendDeep ( [ ] , gd . data ) ;
551
+ var cachedData = Lib . extendDeep ( [ ] , gd . data ) ;
549
552
550
553
Plotly . prependTraces ( gd , {
551
554
x : [ [ 3 , 4 ] , [ 4 , 5 ] ] , 'marker.size' : [ [ 0 , - 1 ] , [ 5 , 6 ] ]
@@ -564,7 +567,7 @@ describe('Test graph_obj', function() {
564
567
565
568
it ( 'prepend is the inverse of extend - with maxPoints' , function ( ) {
566
569
var maxPoints = 3 ;
567
- var cachedData = Plotly . Lib . extendDeep ( [ ] , gd . data ) ;
570
+ var cachedData = Lib . extendDeep ( [ ] , gd . data ) ;
568
571
569
572
Plotly . extendTraces ( gd , {
570
573
x : [ [ 3 , 4 ] , [ 4 , 5 ] ] , 'marker.size' : [ [ 0 , - 1 ] , [ 5 , 6 ] ]
0 commit comments