diff --git a/src/components/Element.js b/src/components/Element.js index 07d93f1..24f1643 100644 --- a/src/components/Element.js +++ b/src/components/Element.js @@ -79,18 +79,12 @@ const Element = ( element.mount(this._ref); // Register Element for automatic token / source / paymentMethod creation - if ( - hocOptions.impliedTokenType || - hocOptions.impliedSourceType || + this.context.registerElement( + element, + hocOptions.impliedTokenType, + hocOptions.impliedSourceType, hocOptions.impliedPaymentMethodType - ) { - this.context.registerElement( - element, - hocOptions.impliedTokenType, - hocOptions.impliedSourceType, - hocOptions.impliedPaymentMethodType - ); - } + ); }); } diff --git a/src/components/Element.test.js b/src/components/Element.test.js index 4d8bfde..34798f1 100644 --- a/src/components/Element.test.js +++ b/src/components/Element.test.js @@ -73,11 +73,17 @@ describe('Element', () => { expect(context.unregisterElement).toHaveBeenCalledWith(elementMock); }); - it('should call the right hooks for a non-registered Element', () => { + it('should call the right hooks for a non-auto-detected Element', () => { const TestElement = Element('test'); const element = mount(, {context}); - expect(context.registerElement).toHaveBeenCalledTimes(0); + expect(context.registerElement).toHaveBeenCalledTimes(1); + expect(context.registerElement).toHaveBeenCalledWith( + elementMock, + undefined, + undefined, + undefined + ); element.unmount(); expect(elementMock.destroy).toHaveBeenCalledTimes(1);