@@ -206,9 +206,11 @@ describe('the register function', function() {
206206 expect ( function ( ) {
207207 Plotly . register ( [ invalidTrace ] ) ;
208208 } ) . toThrowError ( Error , 'Invalid module was attempted to be registered!' ) ;
209+
210+ expect ( Registry . transformsRegistry [ 'mah-transform' ] ) . toBeUndefined ( ) ;
209211 } ) ;
210212
211- it ( 'should throw when if transform module is invalid' , function ( ) {
213+ it ( 'should throw when if transform module is invalid (1) ' , function ( ) {
212214 var missingTransformName = {
213215 moduleType : 'transform'
214216 } ;
@@ -217,15 +219,23 @@ describe('the register function', function() {
217219 Plotly . register ( missingTransformName ) ;
218220 } ) . toThrowError ( Error , 'Transform module *name* must be a string.' ) ;
219221
222+ expect ( Registry . transformsRegistry [ 'mah-transform' ] ) . toBeUndefined ( ) ;
223+ } ) ;
224+
225+ it ( 'should throw when if transform module is invalid (2)' , function ( ) {
220226 var missingTransformFunc = {
221227 moduleType : 'transform' ,
222228 name : 'mah-transform'
223229 } ;
224230
225231 expect ( function ( ) {
226232 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+ } ) ;
228237
238+ it ( 'should not throw when transform module is valid (1)' , function ( ) {
229239 var transformModule = {
230240 moduleType : 'transform' ,
231241 name : 'mah-transform' ,
@@ -238,4 +248,33 @@ describe('the register function', function() {
238248
239249 expect ( Registry . transformsRegistry [ 'mah-transform' ] ) . toBeDefined ( ) ;
240250 } ) ;
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+ } ) ;
241280} ) ;
0 commit comments