diff --git a/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/__snapshots__/renderGenericComponent.test.js.snap b/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/__snapshots__/renderGenericComponent.test.js.snap index 2bf5d07ae..1edb17cf7 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/__snapshots__/renderGenericComponent.test.js.snap +++ b/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/__snapshots__/renderGenericComponent.test.js.snap @@ -1,5 +1,32 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Render Generic Component should hide giftcard container 1`] = ` +{ + "amount": "mocked_amount", + "countryCode": "mocked_countrycode", + "paymentMethodsConfiguration": { + "amazonpay": { + "addressDetails": { + "addressLine1": "test", + "city": "test", + "countryCode": "test", + "name": "test test", + "phoneNumber": "test", + "postalCode": "test", + "stateOrRegion": "test", + }, + "configuration": undefined, + }, + }, + "session": { + "adyenDescriptions": {}, + "id": "mock_id", + "imagePath": "example.com", + "sessionData": "mock_session_data", + }, +} +`; + exports[`Render Generic Component should render 1`] = ` { "amount": "mocked_amount", diff --git a/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/renderGenericComponent.test.js b/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/renderGenericComponent.test.js index aaa744edf..0ca296c47 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/renderGenericComponent.test.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/__tests__/renderGenericComponent.test.js @@ -8,6 +8,37 @@ const { renderGenericComponent } = require('../renderGenericComponent'); const { createSession } = require('../../commons'); const { fetchGiftCards } = require('../../commons'); const store = require('../../../../../store'); +const giftCardHtml = ` +
+ + +
+
+
+
+ Child #1 +
+
+ + + + + + + + +
+ `; +const availableGiftCards = { + giftCards: [ + { + orderAmount: { + currency: '', + value: '', + }, + }, + ], +} beforeEach(() => { window.AdyenCheckout = jest.fn(async () => ({ @@ -35,41 +66,11 @@ beforeEach(() => { imagePath: 'example.com', adyenDescriptions: {}, }); - - fetchGiftCards.mockReturnValue({ - giftCards: [ - { - orderAmount: { - currency: '', - value: '', - }, - }, - ], - }); }); describe('Render Generic Component', () => { it('should render', async () => { - document.body.innerHTML = ` -
- - -
-
-
- Child #1 -
-
- - - - - - - - -
- `; - + fetchGiftCards.mockReturnValue(availableGiftCards); + document.body.innerHTML = giftCardHtml; store.componentsObj = { foo: 'bar', bar: 'baz' }; store.checkoutConfiguration.paymentMethodsConfiguration = { amazonpay: {} }; await renderGenericComponent(); @@ -79,4 +80,20 @@ describe('Render Generic Component', () => { document.querySelector('input[type=radio][name=brandCode]').value, ).toBeTruthy(); }); + + it('should hide giftcard container', async () => { + fetchGiftCards.mockReturnValue({ giftCards: [] }); + document.body.innerHTML = giftCardHtml; + store.componentsObj = { foo: 'bar', bar: 'baz' }; + store.checkoutConfiguration.paymentMethodsConfiguration = { amazonpay: {} }; + await renderGenericComponent(); + expect(createSession).toBeCalled(); + expect(store.checkoutConfiguration).toMatchSnapshot(); + expect( + document.querySelector('.gift-card-selection').style.display, + ).toEqual('none'); + expect( + document.querySelector('.gift-card-separator').style.display, + ).toEqual('none'); + }); }); diff --git a/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/renderGenericComponent.js b/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/renderGenericComponent.js index f94357fd6..72e67af46 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/renderGenericComponent.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/client/default/js/adyen_checkout/renderGenericComponent.js @@ -185,6 +185,8 @@ function setGiftCardContainerVisibility() { if (availableGiftCards.length === 0) { const giftCardContainer = document.querySelector('.gift-card-selection'); giftCardContainer.style.display = 'none'; + const giftCardSeparator = document.querySelector('.gift-card-separator'); + giftCardSeparator.style.display = 'none'; } } diff --git a/src/cartridges/int_adyen_SFRA/cartridge/templates/default/checkout/billing/adyenComponentForm.isml b/src/cartridges/int_adyen_SFRA/cartridge/templates/default/checkout/billing/adyenComponentForm.isml index 8b20ea3df..f030c34c1 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/templates/default/checkout/billing/adyenComponentForm.isml +++ b/src/cartridges/int_adyen_SFRA/cartridge/templates/default/checkout/billing/adyenComponentForm.isml @@ -70,7 +70,7 @@ -
+
${Resource.msg('separator.giftCard', 'adyen', null)}