1
1
var Plotly = require ( '@lib/index' ) ;
2
- var PlotlyInternal = require ( '@src/plotly' ) ;
3
2
var Lib = require ( '@src/lib' ) ;
3
+ var Plots = Plotly . Plots ;
4
4
5
5
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
6
6
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
@@ -19,7 +19,7 @@ describe('Test animate API', function() {
19
19
}
20
20
21
21
function verifyFrameTransitionOrder ( gd , expectedFrames ) {
22
- var calls = PlotlyInternal . transition . calls ;
22
+ var calls = Plots . transition . calls ;
23
23
24
24
expect ( calls . count ( ) ) . toEqual ( expectedFrames . length ) ;
25
25
@@ -35,7 +35,7 @@ describe('Test animate API', function() {
35
35
36
36
mockCopy = Lib . extendDeep ( { } , mock ) ;
37
37
38
- spyOn ( PlotlyInternal , 'transition' ) . and . callFake ( function ( ) {
38
+ spyOn ( Plots , 'transition' ) . and . callFake ( function ( ) {
39
39
// Transition's fake behaviro is to resolve after a short period of time:
40
40
return Promise . resolve ( ) . then ( delay ( 5 ) ) ;
41
41
} ) ;
@@ -61,9 +61,9 @@ describe('Test animate API', function() {
61
61
62
62
it ( 'animates to a frame' , function ( done ) {
63
63
Plotly . animate ( gd , [ 'frame0' ] , { transitionduration : 1.2345 } ) . then ( function ( ) {
64
- expect ( PlotlyInternal . transition ) . toHaveBeenCalled ( ) ;
64
+ expect ( Plots . transition ) . toHaveBeenCalled ( ) ;
65
65
66
- var args = PlotlyInternal . transition . calls . mostRecent ( ) . args ;
66
+ var args = Plots . transition . calls . mostRecent ( ) . args ;
67
67
68
68
// was called with gd, data, layout, traceIndices, transitionConfig:
69
69
expect ( args . length ) . toEqual ( 5 ) ;
@@ -92,7 +92,7 @@ describe('Test animate API', function() {
92
92
it ( 'treats objects as frames' , function ( done ) {
93
93
var frame = { data : [ { x : [ 1 , 2 , 3 ] } ] } ;
94
94
Plotly . animate ( gd , frame , transOpts ) . then ( function ( ) {
95
- expect ( PlotlyInternal . transition . calls . count ( ) ) . toEqual ( 1 ) ;
95
+ expect ( Plots . transition . calls . count ( ) ) . toEqual ( 1 ) ;
96
96
verifyQueueEmpty ( gd ) ;
97
97
} ) . catch ( fail ) . then ( done ) ;
98
98
} ) ;
@@ -101,15 +101,15 @@ describe('Test animate API', function() {
101
101
var frame1 = { data : [ { x : [ 1 , 2 , 3 ] } ] , traces : [ 0 ] , layout : { foo : 'bar' } } ;
102
102
var frame2 = { data : [ { x : [ 3 , 4 , 5 ] } ] , traces : [ 1 ] , layout : { foo : 'baz' } } ;
103
103
Plotly . animate ( gd , [ frame1 , frame2 ] , transOpts ) . then ( function ( ) {
104
- expect ( PlotlyInternal . transition . calls . argsFor ( 0 ) [ 1 ] ) . toEqual ( frame1 . data ) ;
105
- expect ( PlotlyInternal . transition . calls . argsFor ( 0 ) [ 2 ] ) . toEqual ( frame1 . layout ) ;
106
- expect ( PlotlyInternal . transition . calls . argsFor ( 0 ) [ 3 ] ) . toEqual ( frame1 . traces ) ;
104
+ expect ( Plots . transition . calls . argsFor ( 0 ) [ 1 ] ) . toEqual ( frame1 . data ) ;
105
+ expect ( Plots . transition . calls . argsFor ( 0 ) [ 2 ] ) . toEqual ( frame1 . layout ) ;
106
+ expect ( Plots . transition . calls . argsFor ( 0 ) [ 3 ] ) . toEqual ( frame1 . traces ) ;
107
107
108
- expect ( PlotlyInternal . transition . calls . argsFor ( 1 ) [ 1 ] ) . toEqual ( frame2 . data ) ;
109
- expect ( PlotlyInternal . transition . calls . argsFor ( 1 ) [ 2 ] ) . toEqual ( frame2 . layout ) ;
110
- expect ( PlotlyInternal . transition . calls . argsFor ( 1 ) [ 3 ] ) . toEqual ( frame2 . traces ) ;
108
+ expect ( Plots . transition . calls . argsFor ( 1 ) [ 1 ] ) . toEqual ( frame2 . data ) ;
109
+ expect ( Plots . transition . calls . argsFor ( 1 ) [ 2 ] ) . toEqual ( frame2 . layout ) ;
110
+ expect ( Plots . transition . calls . argsFor ( 1 ) [ 3 ] ) . toEqual ( frame2 . traces ) ;
111
111
112
- expect ( PlotlyInternal . transition . calls . count ( ) ) . toEqual ( 2 ) ;
112
+ expect ( Plots . transition . calls . count ( ) ) . toEqual ( 2 ) ;
113
113
verifyQueueEmpty ( gd ) ;
114
114
} ) . catch ( fail ) . then ( done ) ;
115
115
} ) ;
@@ -130,28 +130,28 @@ describe('Test animate API', function() {
130
130
131
131
it ( 'animates to a single frame' , function ( done ) {
132
132
Plotly . animate ( gd , [ 'frame0' ] , transOpts ) . then ( function ( ) {
133
- expect ( PlotlyInternal . transition . calls . count ( ) ) . toEqual ( 1 ) ;
133
+ expect ( Plots . transition . calls . count ( ) ) . toEqual ( 1 ) ;
134
134
verifyQueueEmpty ( gd ) ;
135
135
} ) . catch ( fail ) . then ( done ) ;
136
136
} ) ;
137
137
138
138
it ( 'animates to an empty list' , function ( done ) {
139
139
Plotly . animate ( gd , [ ] , transOpts ) . then ( function ( ) {
140
- expect ( PlotlyInternal . transition . calls . count ( ) ) . toEqual ( 0 ) ;
140
+ expect ( Plots . transition . calls . count ( ) ) . toEqual ( 0 ) ;
141
141
verifyQueueEmpty ( gd ) ;
142
142
} ) . catch ( fail ) . then ( done ) ;
143
143
} ) ;
144
144
145
145
it ( 'animates to a list of frames' , function ( done ) {
146
146
Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , transOpts ) . then ( function ( ) {
147
- expect ( PlotlyInternal . transition . calls . count ( ) ) . toEqual ( 2 ) ;
147
+ expect ( Plots . transition . calls . count ( ) ) . toEqual ( 2 ) ;
148
148
verifyQueueEmpty ( gd ) ;
149
149
} ) . catch ( fail ) . then ( done ) ;
150
150
} ) ;
151
151
152
152
it ( 'animates frames by group' , function ( done ) {
153
153
Plotly . animate ( gd , 'even-frames' , transOpts ) . then ( function ( ) {
154
- expect ( PlotlyInternal . transition . calls . count ( ) ) . toEqual ( 2 ) ;
154
+ expect ( Plots . transition . calls . count ( ) ) . toEqual ( 2 ) ;
155
155
verifyQueueEmpty ( gd ) ;
156
156
} ) . catch ( fail ) . then ( done ) ;
157
157
} ) ;
@@ -165,23 +165,23 @@ describe('Test animate API', function() {
165
165
166
166
it ( 'accepts a single transitionOpts' , function ( done ) {
167
167
Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , { transitionduration : 1.12345 } ) . then ( function ( ) {
168
- var calls = PlotlyInternal . transition . calls ;
168
+ var calls = Plots . transition . calls ;
169
169
expect ( calls . argsFor ( 0 ) [ 4 ] . transitionduration ) . toEqual ( 1.12345 ) ;
170
170
expect ( calls . argsFor ( 1 ) [ 4 ] . transitionduration ) . toEqual ( 1.12345 ) ;
171
171
} ) . catch ( fail ) . then ( done ) ;
172
172
} ) ;
173
173
174
174
it ( 'accepts an array of transitionOpts' , function ( done ) {
175
175
Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , [ { transitionduration : 1.123 } , { transitionduration : 1.456 } ] ) . then ( function ( ) {
176
- var calls = PlotlyInternal . transition . calls ;
176
+ var calls = Plots . transition . calls ;
177
177
expect ( calls . argsFor ( 0 ) [ 4 ] . transitionduration ) . toEqual ( 1.123 ) ;
178
178
expect ( calls . argsFor ( 1 ) [ 4 ] . transitionduration ) . toEqual ( 1.456 ) ;
179
179
} ) . catch ( fail ) . then ( done ) ;
180
180
} ) ;
181
181
182
182
it ( 'falls back to transitionOpts[0] if not enough supplied in array' , function ( done ) {
183
183
Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , [ { transitionduration : 1.123 } ] ) . then ( function ( ) {
184
- var calls = PlotlyInternal . transition . calls ;
184
+ var calls = Plots . transition . calls ;
185
185
expect ( calls . argsFor ( 0 ) [ 4 ] . transitionduration ) . toEqual ( 1.123 ) ;
186
186
expect ( calls . argsFor ( 1 ) [ 4 ] . transitionduration ) . toEqual ( 1.123 ) ;
187
187
} ) . catch ( fail ) . then ( done ) ;
@@ -273,7 +273,7 @@ describe('Test animate API', function() {
273
273
starts ++ ;
274
274
} ) . on ( 'plotly_animated' , function ( ) {
275
275
ends ++ ;
276
- expect ( PlotlyInternal . transition . calls . count ( ) ) . toEqual ( 4 ) ;
276
+ expect ( Plots . transition . calls . count ( ) ) . toEqual ( 4 ) ;
277
277
expect ( starts ) . toEqual ( 1 ) ;
278
278
} ) ;
279
279
@@ -287,7 +287,7 @@ describe('Test animate API', function() {
287
287
it ( 'an empty list with immediate dumps previous frames' , function ( done ) {
288
288
Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , { frameduration : 50 } ) ;
289
289
Plotly . animate ( gd , [ ] , null , { immediate : true } ) . then ( function ( ) {
290
- expect ( PlotlyInternal . transition . calls . count ( ) ) . toEqual ( 1 ) ;
290
+ expect ( Plots . transition . calls . count ( ) ) . toEqual ( 1 ) ;
291
291
verifyQueueEmpty ( gd ) ;
292
292
} ) . catch ( fail ) . then ( done ) ;
293
293
} ) ;
@@ -343,7 +343,7 @@ describe('Test animate API', function() {
343
343
Plotly . animate ( gd , [ 'frame0' , 'frame1' ] , { transitionduration : 200 , frameduration : 20 } ) . then ( function ( ) {
344
344
expect ( starts ) . toEqual ( 1 ) ;
345
345
expect ( ends ) . toEqual ( 1 ) ;
346
- expect ( PlotlyInternal . transition . calls . count ( ) ) . toEqual ( 2 ) ;
346
+ expect ( Plots . transition . calls . count ( ) ) . toEqual ( 2 ) ;
347
347
verifyQueueEmpty ( gd ) ;
348
348
} ) . catch ( fail ) . then ( done ) ;
349
349
} ) ;
0 commit comments