1- var Plotly = require ( '@src/plotly' ) ;
1+ var Plotly = require ( '@src' ) ;
2+ var PlotlyInternal = require ( '@src/plotly' ) ;
23var Plots = require ( '@src/plots/plots' ) ;
4+ var Lib = require ( '@src/lib' ) ;
35var Scatter = require ( '@src/traces/scatter' ) ;
46var Bar = require ( '@src/traces/bar' ) ;
57var Legend = require ( '@src/components/legend' ) ;
68
7- describe ( 'Test graph_obj' , function ( ) {
9+
10+ describe ( 'Test plot api' , function ( ) {
811 'use strict' ;
912
1013 describe ( 'Plotly.restyle' , function ( ) {
@@ -67,7 +70,7 @@ describe('Test graph_obj', function() {
6770 { 'name' : 'd' }
6871 ]
6972 } ;
70- spyOn ( Plotly , 'redraw' ) ;
73+ spyOn ( PlotlyInternal , 'redraw' ) ;
7174 } ) ;
7275
7376 it ( 'should throw an error when indices are omitted' , function ( ) {
@@ -103,7 +106,7 @@ describe('Test graph_obj', function() {
103106
104107 Plotly . deleteTraces ( gd , - 1 ) ;
105108 expect ( gd . data ) . toEqual ( expectedData ) ;
106- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
109+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
107110
108111 } ) ;
109112
@@ -115,7 +118,7 @@ describe('Test graph_obj', function() {
115118
116119 Plotly . deleteTraces ( gd , [ 0 , 3 ] ) ;
117120 expect ( gd . data ) . toEqual ( expectedData ) ;
118- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
121+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
119122
120123 } ) ;
121124
@@ -127,7 +130,7 @@ describe('Test graph_obj', function() {
127130
128131 Plotly . deleteTraces ( gd , [ 3 , 0 ] ) ;
129132 expect ( gd . data ) . toEqual ( expectedData ) ;
130- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
133+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
131134
132135 } ) ;
133136
@@ -138,8 +141,8 @@ describe('Test graph_obj', function() {
138141
139142 beforeEach ( function ( ) {
140143 gd = { data : [ { 'name' : 'a' } , { 'name' : 'b' } ] } ;
141- spyOn ( Plotly , 'redraw' ) ;
142- spyOn ( Plotly , 'moveTraces' ) ;
144+ spyOn ( PlotlyInternal , 'redraw' ) ;
145+ spyOn ( PlotlyInternal , 'moveTraces' ) ;
143146 } ) ;
144147
145148 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() {
186189 expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
187190 expect ( gd . data [ 3 ] . name ) . toBeDefined ( ) ;
188191 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 ( ) ;
191194 } ) ;
192195
193196 it ( 'should work when newIndices is defined' , function ( ) {
@@ -196,8 +199,8 @@ describe('Test graph_obj', function() {
196199 expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
197200 expect ( gd . data [ 3 ] . name ) . toBeDefined ( ) ;
198201 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 ] ) ;
201204
202205 } ) ;
203206
@@ -207,17 +210,17 @@ describe('Test graph_obj', function() {
207210 expect ( gd . data [ 2 ] . uid ) . toBeDefined ( ) ;
208211 expect ( gd . data [ 3 ] . name ) . toBeDefined ( ) ;
209212 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 ] ) ;
212215
213216 } ) ;
214217
215218 it ( 'should work when newIndices is an integer' , function ( ) {
216219 Plotly . addTraces ( gd , { 'name' : 'c' } , 0 ) ;
217220 expect ( gd . data [ 2 ] . name ) . toBeDefined ( ) ;
218221 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 ] ) ;
221224
222225 } ) ;
223226 } ) ;
@@ -233,7 +236,7 @@ describe('Test graph_obj', function() {
233236 { 'name' : 'd' }
234237 ]
235238 } ;
236- spyOn ( Plotly , 'redraw' ) ;
239+ spyOn ( PlotlyInternal , 'redraw' ) ;
237240 } ) ;
238241
239242 it ( 'throw an error when index arrays are unequal' , function ( ) {
@@ -301,7 +304,7 @@ describe('Test graph_obj', function() {
301304
302305 Plotly . moveTraces ( gd , 0 , 1 ) ;
303306 expect ( gd . data ) . toEqual ( expectedData ) ;
304- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
307+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
305308
306309 } ) ;
307310
@@ -315,7 +318,7 @@ describe('Test graph_obj', function() {
315318
316319 Plotly . moveTraces ( gd , [ 3 , 1 ] , [ 0 , 3 ] ) ;
317320 expect ( gd . data ) . toEqual ( expectedData ) ;
318- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
321+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
319322
320323 } ) ;
321324
@@ -329,7 +332,7 @@ describe('Test graph_obj', function() {
329332
330333 Plotly . moveTraces ( gd , [ 3 , 0 ] ) ;
331334 expect ( gd . data ) . toEqual ( expectedData ) ;
332- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
335+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
333336
334337 } ) ;
335338
@@ -343,7 +346,7 @@ describe('Test graph_obj', function() {
343346
344347 Plotly . moveTraces ( gd , 1 , - 2 ) ;
345348 expect ( gd . data ) . toEqual ( expectedData ) ;
346- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
349+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
347350
348351 } ) ;
349352 } ) ;
@@ -367,7 +370,7 @@ describe('Test graph_obj', function() {
367370 } ;
368371 }
369372
370- spyOn ( Plotly , 'redraw' ) ;
373+ spyOn ( PlotlyInternal , 'redraw' ) ;
371374 spyOn ( Plotly . Queue , 'add' ) ;
372375 } ) ;
373376
@@ -470,7 +473,7 @@ describe('Test graph_obj', function() {
470473 { x : [ 1 , 2 , 3 , 4 , 5 ] , marker : { size : [ 2 , 3 , 4 , 5 , 6 ] } }
471474 ] ) ;
472475
473- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
476+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
474477 } ) ;
475478
476479 it ( 'should extend and window traces with update keys' , function ( ) {
@@ -523,11 +526,11 @@ describe('Test graph_obj', function() {
523526 { x : [ ] , marker : { size : [ ] } }
524527 ] ) ;
525528
526- expect ( Plotly . redraw ) . toHaveBeenCalled ( ) ;
529+ expect ( PlotlyInternal . redraw ) . toHaveBeenCalled ( ) ;
527530 } ) ;
528531
529532 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 ) ;
531534
532535 Plotly . extendTraces ( gd , {
533536 x : [ [ 3 , 4 ] , [ 4 , 5 ] ] , 'marker.size' : [ [ 0 , - 1 ] , [ 5 , 6 ] ]
@@ -545,7 +548,7 @@ describe('Test graph_obj', function() {
545548
546549
547550 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 ) ;
549552
550553 Plotly . prependTraces ( gd , {
551554 x : [ [ 3 , 4 ] , [ 4 , 5 ] ] , 'marker.size' : [ [ 0 , - 1 ] , [ 5 , 6 ] ]
@@ -564,7 +567,7 @@ describe('Test graph_obj', function() {
564567
565568 it ( 'prepend is the inverse of extend - with maxPoints' , function ( ) {
566569 var maxPoints = 3 ;
567- var cachedData = Plotly . Lib . extendDeep ( [ ] , gd . data ) ;
570+ var cachedData = Lib . extendDeep ( [ ] , gd . data ) ;
568571
569572 Plotly . extendTraces ( gd , {
570573 x : [ [ 3 , 4 ] , [ 4 , 5 ] ] , 'marker.size' : [ [ 0 , - 1 ] , [ 5 , 6 ] ]
0 commit comments