@@ -206,9 +206,11 @@ describe('the register function', function() {
206
206
expect ( function ( ) {
207
207
Plotly . register ( [ invalidTrace ] ) ;
208
208
} ) . toThrowError ( Error , 'Invalid module was attempted to be registered!' ) ;
209
+
210
+ expect ( Registry . transformsRegistry [ 'mah-transform' ] ) . toBeUndefined ( ) ;
209
211
} ) ;
210
212
211
- it ( 'should throw when if transform module is invalid' , function ( ) {
213
+ it ( 'should throw when if transform module is invalid (1) ' , function ( ) {
212
214
var missingTransformName = {
213
215
moduleType : 'transform'
214
216
} ;
@@ -217,15 +219,23 @@ describe('the register function', function() {
217
219
Plotly . register ( missingTransformName ) ;
218
220
} ) . toThrowError ( Error , 'Transform module *name* must be a string.' ) ;
219
221
222
+ expect ( Registry . transformsRegistry [ 'mah-transform' ] ) . toBeUndefined ( ) ;
223
+ } ) ;
224
+
225
+ it ( 'should throw when if transform module is invalid (2)' , function ( ) {
220
226
var missingTransformFunc = {
221
227
moduleType : 'transform' ,
222
228
name : 'mah-transform'
223
229
} ;
224
230
225
231
expect ( function ( ) {
226
232
Plotly . register ( missingTransformFunc ) ;
227
- } ) . toThrowError ( Error , 'Transform module mah-transform is missing a *transform* function.' ) ;
233
+ } ) . toThrowError ( Error , 'Transform module mah-transform is missing a *transform* or *calcTransform* method.' ) ;
234
+
235
+ expect ( Registry . transformsRegistry [ 'mah-transform' ] ) . toBeUndefined ( ) ;
236
+ } ) ;
228
237
238
+ it ( 'should not throw when transform module is valid (1)' , function ( ) {
229
239
var transformModule = {
230
240
moduleType : 'transform' ,
231
241
name : 'mah-transform' ,
@@ -238,4 +248,33 @@ describe('the register function', function() {
238
248
239
249
expect ( Registry . transformsRegistry [ 'mah-transform' ] ) . toBeDefined ( ) ;
240
250
} ) ;
251
+
252
+ it ( 'should not throw when transform module is valid (2)' , function ( ) {
253
+ var transformModule = {
254
+ moduleType : 'transform' ,
255
+ name : 'mah-transform' ,
256
+ calcTransform : function ( ) { }
257
+ } ;
258
+
259
+ expect ( function ( ) {
260
+ Plotly . register ( transformModule ) ;
261
+ } ) . not . toThrow ( ) ;
262
+
263
+ expect ( Registry . transformsRegistry [ 'mah-transform' ] ) . toBeDefined ( ) ;
264
+ } ) ;
265
+
266
+ it ( 'should not throw when transform module is valid (3)' , function ( ) {
267
+ var transformModule = {
268
+ moduleType : 'transform' ,
269
+ name : 'mah-transform' ,
270
+ transform : function ( ) { } ,
271
+ calcTransform : function ( ) { }
272
+ } ;
273
+
274
+ expect ( function ( ) {
275
+ Plotly . register ( transformModule ) ;
276
+ } ) . not . toThrow ( ) ;
277
+
278
+ expect ( Registry . transformsRegistry [ 'mah-transform' ] ) . toBeDefined ( ) ;
279
+ } ) ;
241
280
} ) ;
0 commit comments