diff --git a/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout-method/swag-paypal-checkout-method.spec.js b/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout-method/swag-paypal-checkout-method.spec.ts similarity index 86% rename from src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout-method/swag-paypal-checkout-method.spec.js rename to src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout-method/swag-paypal-checkout-method.spec.ts index a35c7fa87..b5899bcac 100644 --- a/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout-method/swag-paypal-checkout-method.spec.js +++ b/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout-method/swag-paypal-checkout-method.spec.ts @@ -1,15 +1,15 @@ import { mount } from '@vue/test-utils'; -import 'SwagPayPal/module/swag-paypal/components/swag-paypal-checkout-method'; +import SwagPayPalCheckoutMethod from '.'; -Shopware.Component.register('swag-paypal-checkout-method', () => import('.')); +Shopware.Component.register('swag-paypal-checkout-method', Promise.resolve(SwagPayPalCheckoutMethod)); Shopware.Component.register('swag-paypal-checkout-domain-association', () => import('../swag-paypal-checkout-domain-association')); async function createWrapper(customOptions = {}) { const options = { global: { mocks: { - $tc: (key) => key, - $te: (key) => key, + $tc: (key: string) => key, + $te: (key: string) => key, }, provide: { acl: { @@ -37,7 +37,7 @@ async function createWrapper(customOptions = {}) { }, }; return mount( - await Shopware.Component.build('swag-paypal-checkout-method'), + await Shopware.Component.build('swag-paypal-checkout-method') as typeof SwagPayPalCheckoutMethod, Shopware.Utils.object.mergeWith(options, customOptions), ); } @@ -45,7 +45,7 @@ describe('Paypal Domain Association Component', () => { it('should be a Vue.js component', async () => { const wrapper = await createWrapper(); - await new Promise(process.nextTick); + await flushPromises(); expect(wrapper.vm).toBeTruthy(); }); @@ -59,7 +59,7 @@ describe('Paypal Domain Association Component', () => { }, }); - await new Promise(process.nextTick); + await flushPromises(); let alert = wrapper.find('.swag-plugin-apple-pay-warning'); @@ -73,10 +73,10 @@ describe('Paypal Domain Association Component', () => { translated: { name: 'Apple Pay', }, - }, + } as TEntity<'payment_method'>, }); - await new Promise(process.nextTick); + await flushPromises(); alert = wrapper.find('.swag-plugin-apple-pay-warning'); @@ -92,7 +92,7 @@ describe('Paypal Domain Association Component', () => { }, }); - await new Promise(process.nextTick); + await flushPromises(); let alert = wrapper.find('.swag-plugin-apple-pay-warning'); @@ -106,10 +106,10 @@ describe('Paypal Domain Association Component', () => { translated: { name: 'Apple Pay', }, - }, + } as TEntity<'payment_method'>, }); - await new Promise(process.nextTick); + await flushPromises(); alert = wrapper.find('.swag-plugin-apple-pay-warning'); @@ -125,14 +125,14 @@ describe('Paypal Domain Association Component', () => { }, }); - await new Promise(process.nextTick); + await flushPromises(); expect(wrapper.find('.swag-plugin-apple-pay-warning').exists()).toBeTruthy(); const button = wrapper.find('.sw-alert__close'); await button.trigger('click'); - await new Promise(process.nextTick); + await flushPromises(); expect(wrapper.find('.swag-plugin-apple-pay-warning').exists()).toBeFalsy(); }); diff --git a/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout/swag-paypal-checkout.spec.js b/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout/swag-paypal-checkout.spec.ts similarity index 87% rename from src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout/swag-paypal-checkout.spec.js rename to src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout/swag-paypal-checkout.spec.ts index 849388651..3fd40157b 100644 --- a/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout/swag-paypal-checkout.spec.js +++ b/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-checkout/swag-paypal-checkout.spec.ts @@ -1,7 +1,7 @@ import { mount } from '@vue/test-utils'; -import 'SwagPayPal/module/swag-paypal/components/swag-paypal-checkout'; +import SwagPayPalCheckout from '.'; -Shopware.Component.register('swag-paypal-checkout', () => import('.')); +Shopware.Component.register('swag-paypal-checkout', Promise.resolve(SwagPayPalCheckout)); const onboardingCallbackLive = 'onboardingCallbackLive'; const onboardingCallbackSandbox = 'onboardingUrlSandbox'; @@ -10,7 +10,7 @@ async function createWrapper(customOptions = {}) { const options = { global: { mocks: { - $tc: (key) => key, + $tc: (key: string) => key, }, provide: { acl: { @@ -50,10 +50,11 @@ async function createWrapper(customOptions = {}) { }, }; - return mount(await Shopware.Component.build('swag-paypal-checkout'), { - ...options, - ...customOptions, - }); + return mount( + await Shopware.Component.build('swag-paypal-checkout') as typeof SwagPayPalCheckout, + // @ts-expect-error - data() is incomplete + Shopware.Utils.object.merge(options, customOptions), + ); } /** diff --git a/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-cross-border/swag-paypal-cross-border.spec.js b/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-cross-border/swag-paypal-cross-border.spec.ts similarity index 87% rename from src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-cross-border/swag-paypal-cross-border.spec.js rename to src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-cross-border/swag-paypal-cross-border.spec.ts index 93a14aca9..4c220f870 100644 --- a/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-cross-border/swag-paypal-cross-border.spec.js +++ b/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-cross-border/swag-paypal-cross-border.spec.ts @@ -1,11 +1,12 @@ import { mount } from '@vue/test-utils'; +import SwagPayPalCrossBorder from '.'; -Shopware.Component.register('swag-paypal-cross-border', () => import('.')); +Shopware.Component.register('swag-paypal-cross-border', Promise.resolve(SwagPayPalCrossBorder)); async function createWrapper(customOptions = {}) { const options = { global: { - mocks: { $tc: (key) => key, $t: (key) => key }, + mocks: { $tc: (key: string) => key, $t: (key: string) => key }, provide: { acl: { can: () => true }, }, @@ -30,7 +31,7 @@ async function createWrapper(customOptions = {}) { }; return mount( - await Shopware.Component.build('swag-paypal-cross-border'), + await Shopware.Component.build('swag-paypal-cross-border') as typeof SwagPayPalCrossBorder, Shopware.Utils.object.mergeWith(options, customOptions), ); } diff --git a/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-vaulting/swag-paypal-vaulting.spec.js b/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-vaulting/swag-paypal-vaulting.spec.ts similarity index 80% rename from src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-vaulting/swag-paypal-vaulting.spec.js rename to src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-vaulting/swag-paypal-vaulting.spec.ts index e7d922dbf..0a5014ee0 100644 --- a/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-vaulting/swag-paypal-vaulting.spec.js +++ b/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-vaulting/swag-paypal-vaulting.spec.ts @@ -1,7 +1,7 @@ import { mount } from '@vue/test-utils'; -import 'SwagPayPal/module/swag-paypal/components/swag-paypal-vaulting'; +import SwagPayPalVaulting from '.'; -Shopware.Component.register('swag-paypal-vaulting', () => import('.')); +Shopware.Component.register('swag-paypal-vaulting', Promise.resolve(SwagPayPalVaulting)); const onboardingCallbackLive = 'onboardingCallbackLive'; const onboardingCallbackSandbox = 'onboardingUrlSandbox'; @@ -10,7 +10,7 @@ async function createWrapper(customOptions = {}) { const options = { global: { mocks: { - $tc: (key) => key, + $tc: (key: string) => key, }, provide: { acl: { @@ -54,7 +54,7 @@ async function createWrapper(customOptions = {}) { }; return mount( - await Shopware.Component.build('swag-paypal-vaulting'), + await Shopware.Component.build('swag-paypal-vaulting') as typeof SwagPayPalVaulting, Shopware.Utils.object.mergeWith(options, customOptions), ); } @@ -63,7 +63,7 @@ describe('Paypal Vaulting Component', () => { it('should be a Vue.js component', async () => { const wrapper = await createWrapper(); - await new Promise(process.nextTick); + await flushPromises(); expect(wrapper.vm).toBeTruthy(); }); @@ -94,10 +94,10 @@ describe('Paypal Vaulting Component', () => { it('should render onboarding buttons', async () => { const wrapper = await createWrapper(); - await new Promise(process.nextTick); + await flushPromises(); - const liveButton = await wrapper.find("a[data-paypal-onboard-complete='onboardingCallbackLive']"); - const sandboxButton = await wrapper.find("a[data-paypal-onboard-complete='onboardingCallbackSandbox']"); + const liveButton = wrapper.find("a[data-paypal-onboard-complete='onboardingCallbackLive']"); + const sandboxButton = wrapper.find("a[data-paypal-onboard-complete='onboardingCallbackSandbox']"); expect(liveButton.exists()).toBe(true); expect(sandboxButton.exists()).toBe(true); @@ -106,9 +106,9 @@ describe('Paypal Vaulting Component', () => { it('should link to the live onboarding guide', async () => { const wrapper = await createWrapper(); - await new Promise(process.nextTick); + await flushPromises(); - const liveButton = await wrapper.find("a[data-paypal-onboard-complete='onboardingCallbackLive']"); + const liveButton = wrapper.find("a[data-paypal-onboard-complete='onboardingCallbackLive']"); expect(liveButton.attributes('href')).toBe(onboardingCallbackLive); }); @@ -116,9 +116,9 @@ describe('Paypal Vaulting Component', () => { it('should link to the sandbox onboarding guide', async () => { const wrapper = await createWrapper(); - await new Promise(process.nextTick); + await flushPromises(); - const sandboxButton = await wrapper.find("a[data-paypal-onboard-complete='onboardingCallbackSandbox']"); + const sandboxButton = wrapper.find("a[data-paypal-onboard-complete='onboardingCallbackSandbox']"); expect(sandboxButton.attributes('href')).toBe(onboardingCallbackSandbox); }); diff --git a/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-webhook/swag-paypal-webhook.spec.js b/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-webhook/swag-paypal-webhook.spec.ts similarity index 94% rename from src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-webhook/swag-paypal-webhook.spec.js rename to src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-webhook/swag-paypal-webhook.spec.ts index 60780354f..607a5249e 100644 --- a/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-webhook/swag-paypal-webhook.spec.js +++ b/src/Resources/app/administration/src/module/swag-paypal/components/swag-paypal-webhook/swag-paypal-webhook.spec.ts @@ -1,12 +1,12 @@ import { mount } from '@vue/test-utils'; -import 'SwagPayPal/module/swag-paypal/components/swag-paypal-webhook'; +import SwagPayPalWebhook from '.'; -Shopware.Component.register('swag-paypal-webhook', () => import('.')); +Shopware.Component.register('swag-paypal-webhook', Promise.resolve(SwagPayPalWebhook)); async function createWrapper(customOptions = {}) { const options = { global: { - mocks: { $tc: (key) => key }, + mocks: { $tc: (key: string) => key }, provide: { acl: { can: () => true, @@ -27,8 +27,8 @@ async function createWrapper(customOptions = {}) { }; return mount( - await Shopware.Component.build('swag-paypal-webhook'), - Shopware.Utils.object.mergeWith(options, customOptions), + await Shopware.Component.build('swag-paypal-webhook') as typeof SwagPayPalWebhook, + Shopware.Utils.object.merge(options, customOptions), ); }