1
1
var Plotly = require ( '@src/plotly' ) ;
2
+ var Plots = require ( '@src/plots/plots' ) ;
2
3
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
3
4
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
4
5
5
6
6
- describe ( 'Test Plotly.Plots' , function ( ) {
7
+
8
+ describe ( 'Test Plots' , function ( ) {
7
9
'use strict' ;
8
10
9
- describe ( 'Plotly. Plots.supplyLayoutGlobalDefaults should' , function ( ) {
11
+ describe ( 'Plots.supplyLayoutGlobalDefaults should' , function ( ) {
10
12
var layoutIn ,
11
13
layoutOut ,
12
14
expected ;
13
15
14
- var supplyLayoutDefaults = Plotly . Plots . supplyLayoutGlobalDefaults ;
16
+ var supplyLayoutDefaults = Plots . supplyLayoutGlobalDefaults ;
15
17
16
18
beforeEach ( function ( ) {
17
19
layoutOut = { } ;
@@ -65,8 +67,8 @@ describe('Test Plotly.Plots', function() {
65
67
66
68
} ) ;
67
69
68
- describe ( 'Plotly. Plots.supplyDataDefaults' , function ( ) {
69
- var supplyDataDefaults = Plotly . Plots . supplyDataDefaults ,
70
+ describe ( 'Plots.supplyDataDefaults' , function ( ) {
71
+ var supplyDataDefaults = Plots . supplyDataDefaults ,
70
72
layout = { } ;
71
73
72
74
var traceIn , traceOut ;
@@ -98,8 +100,8 @@ describe('Test Plotly.Plots', function() {
98
100
} ) ;
99
101
} ) ;
100
102
101
- describe ( 'Plotly. Plots.getSubplotIds' , function ( ) {
102
- var getSubplotIds = Plotly . Plots . getSubplotIds ;
103
+ describe ( 'Plots.getSubplotIds' , function ( ) {
104
+ var getSubplotIds = Plots . getSubplotIds ;
103
105
var layout ;
104
106
105
107
it ( 'returns scene ids' , function ( ) {
@@ -143,8 +145,8 @@ describe('Test Plotly.Plots', function() {
143
145
} ) ;
144
146
} ) ;
145
147
146
- describe ( 'Plotly. Plots.getSubplotIdsInData' , function ( ) {
147
- var getSubplotIdsInData = Plotly . Plots . getSubplotIdsInData ;
148
+ describe ( 'Plots.getSubplotIdsInData' , function ( ) {
149
+ var getSubplotIdsInData = Plots . getSubplotIdsInData ;
148
150
149
151
var ids , data ;
150
152
@@ -173,11 +175,11 @@ describe('Test Plotly.Plots', function() {
173
175
174
176
} ) ;
175
177
176
- describe ( 'Plotly. Plots.register, getModule, and traceIs' , function ( ) {
178
+ describe ( 'Plots.register, getModule, and traceIs' , function ( ) {
177
179
beforeEach ( function ( ) {
178
- this . modulesKeys = Object . keys ( Plotly . Plots . modules ) ;
179
- this . allTypesKeys = Object . keys ( Plotly . Plots . allTypes ) ;
180
- this . allCategoriesKeys = Object . keys ( Plotly . Plots . allCategories ) ;
180
+ this . modulesKeys = Object . keys ( Plots . modules ) ;
181
+ this . allTypesKeys = Object . keys ( Plots . allTypes ) ;
182
+ this . allCategoriesKeys = Object . keys ( Plots . allCategories ) ;
181
183
182
184
this . fakeModule = {
183
185
calc : function ( ) { return 42 ; } ,
@@ -187,7 +189,7 @@ describe('Test Plotly.Plots', function() {
187
189
plot : function ( ) { throw new Error ( 'nope!' ) ; }
188
190
} ;
189
191
190
- Plotly . Plots . register ( this . fakeModule , 'newtype' , [ 'red' , 'green' ] ) ;
192
+ Plots . register ( this . fakeModule , 'newtype' , [ 'red' , 'green' ] ) ;
191
193
192
194
spyOn ( console , 'warn' ) ;
193
195
} ) ;
@@ -199,52 +201,50 @@ describe('Test Plotly.Plots', function() {
199
201
} ) ;
200
202
}
201
203
202
- revertObj ( Plotly . Plots . modules , this . modulesKeys ) ;
203
- revertObj ( Plotly . Plots . allTypes , this . allTypesKeys ) ;
204
- revertObj ( Plotly . Plots . allCategories , this . allCategoriesKeys ) ;
204
+ revertObj ( Plots . modules , this . modulesKeys ) ;
205
+ revertObj ( Plots . allTypes , this . allTypesKeys ) ;
206
+ revertObj ( Plots . allCategories , this . allCategoriesKeys ) ;
205
207
} ) ;
206
208
207
- it ( 'should error on attempts to reregister a type' , function ( ) {
208
- var fm2 = this . fakeModule2 ;
209
- expect ( function ( ) { Plotly . Plots . register ( fm2 , 'newtype' , [ 'yellow' , 'blue' ] ) ; } )
210
- . toThrow ( new Error ( 'type newtype already registered' ) ) ;
211
- expect ( Plotly . Plots . allCategories . yellow ) . toBeUndefined ( ) ;
209
+ it ( 'should warn on attempts to reregister a type' , function ( ) {
210
+ Plots . register ( this . fakeModule2 , 'newtype' , [ 'yellow' , 'blue' ] ) ;
211
+ expect ( Plots . allCategories . yellow ) . toBeUndefined ( ) ;
212
212
} ) ;
213
213
214
214
it ( 'should find the module for a type' , function ( ) {
215
- expect ( Plotly . Plots . getModule ( 'newtype' ) ) . toBe ( this . fakeModule ) ;
216
- expect ( Plotly . Plots . getModule ( { type : 'newtype' } ) ) . toBe ( this . fakeModule ) ;
215
+ expect ( Plots . getModule ( 'newtype' ) ) . toBe ( this . fakeModule ) ;
216
+ expect ( Plots . getModule ( { type : 'newtype' } ) ) . toBe ( this . fakeModule ) ;
217
217
} ) ;
218
218
219
219
it ( 'should return false for types it doesn\'t know' , function ( ) {
220
- expect ( Plotly . Plots . getModule ( 'notatype' ) ) . toBe ( false ) ;
221
- expect ( Plotly . Plots . getModule ( { type : 'notatype' } ) ) . toBe ( false ) ;
222
- expect ( Plotly . Plots . getModule ( { type : 'newtype' , r : 'this is polar' } ) ) . toBe ( false ) ;
220
+ expect ( Plots . getModule ( 'notatype' ) ) . toBe ( false ) ;
221
+ expect ( Plots . getModule ( { type : 'notatype' } ) ) . toBe ( false ) ;
222
+ expect ( Plots . getModule ( { type : 'newtype' , r : 'this is polar' } ) ) . toBe ( false ) ;
223
223
} ) ;
224
224
225
225
it ( 'should find the categories for this type' , function ( ) {
226
- expect ( Plotly . Plots . traceIs ( 'newtype' , 'red' ) ) . toBe ( true ) ;
227
- expect ( Plotly . Plots . traceIs ( { type : 'newtype' } , 'red' ) ) . toBe ( true ) ;
226
+ expect ( Plots . traceIs ( 'newtype' , 'red' ) ) . toBe ( true ) ;
227
+ expect ( Plots . traceIs ( { type : 'newtype' } , 'red' ) ) . toBe ( true ) ;
228
228
} ) ;
229
229
230
230
it ( 'should not find other real categories' , function ( ) {
231
- expect ( Plotly . Plots . traceIs ( 'newtype' , 'cartesian' ) ) . toBe ( false ) ;
232
- expect ( Plotly . Plots . traceIs ( { type : 'newtype' } , 'cartesian' ) ) . toBe ( false ) ;
231
+ expect ( Plots . traceIs ( 'newtype' , 'cartesian' ) ) . toBe ( false ) ;
232
+ expect ( Plots . traceIs ( { type : 'newtype' } , 'cartesian' ) ) . toBe ( false ) ;
233
233
expect ( console . warn ) . not . toHaveBeenCalled ( ) ;
234
234
} ) ;
235
235
} ) ;
236
236
237
- describe ( 'Plotly. Plots.registerSubplot' , function ( ) {
237
+ describe ( 'Plots.registerSubplot' , function ( ) {
238
238
var fake = {
239
239
name : 'fake' ,
240
240
attr : 'abc' ,
241
241
idRoot : 'cba' ,
242
242
attributes : { stuff : { 'more stuff' : 102102 } }
243
243
} ;
244
244
245
- Plotly . Plots . registerSubplot ( fake ) ;
245
+ Plots . registerSubplot ( fake ) ;
246
246
247
- var subplotsRegistry = Plotly . Plots . subplotsRegistry ;
247
+ var subplotsRegistry = Plots . subplotsRegistry ;
248
248
249
249
it ( 'should register attr, idRoot and attributes' , function ( ) {
250
250
expect ( subplotsRegistry . fake . attr ) . toEqual ( 'abc' ) ;
@@ -307,7 +307,7 @@ describe('Test Plotly.Plots', function() {
307
307
308
308
} ) ;
309
309
310
- describe ( 'Plotly. Plots.purge' , function ( ) {
310
+ describe ( 'Plots.purge' , function ( ) {
311
311
var gd ;
312
312
313
313
beforeEach ( function ( done ) {
@@ -324,7 +324,7 @@ describe('Test Plotly.Plots', function() {
324
324
'_hmpixcount' , '_hmlumcount'
325
325
] ;
326
326
327
- Plotly . Plots . purge ( gd ) ;
327
+ Plots . purge ( gd ) ;
328
328
expect ( Object . keys ( gd ) ) . toEqual ( expectedKeys ) ;
329
329
expect ( gd . data ) . toBeUndefined ( ) ;
330
330
expect ( gd . layout ) . toBeUndefined ( ) ;
0 commit comments