Skip to content

Commit

Permalink
Rename feature test DesktopContent to BannerContent
Browse files Browse the repository at this point in the history
  • Loading branch information
Abban committed May 26, 2023
1 parent 148f0d7 commit 8c7ac6c
Show file tree
Hide file tree
Showing 13 changed files with 451 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ npm-debug.log
node_modules/
dist/
!dist/index.html
coverage
451 changes: 419 additions & 32 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"lint:ts": "vue-tsc --noEmit",
"lint:css": "stylelint '**/*.{scss,vue}'",
"ci": "npm-run-all lint test",
"coverage": "vitest run --coverage",
"update-content": "npm update fundraising-frontend-content"
},
"keywords": [],
Expand All @@ -30,8 +31,10 @@
"vue": "^3.2.45"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.2.0",
"@types/jsdom": "^21.1.1",
"@vitejs/plugin-vue": "^4.2.1",
"@vitest/coverage-c8": "^0.31.1",
"@vue/eslint-config-typescript": "^11.0.3",
"@vue/test-utils": "^2.3.2",
"@vue/tsconfig": "^0.1.3",
Expand All @@ -48,7 +51,6 @@
"npm-check-updates": "^16.7.10",
"npm-run-all": "^4.1.5",
"rimraf": "^5.0.1",
"@rushstack/eslint-patch": "^1.2.0",
"sass": "^1.62.1",
"sass-loader": "^13.2.2",
"string-replace-loader": "^3.1.0",
Expand Down
11 changes: 6 additions & 5 deletions test/banners/desktop/components/BannerCtrl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn';
import { TrackerStub } from '@test/fixtures/TrackerStub';
import { softCloseFeatures } from '@test/features/SoftCloseDesktop';
import { useOfFundsFeatures } from '@test/features/UseOfFunds';
import { desktopContentDisplaySwitchFeatures, desktopContentFeatures } from '@test/features/DesktopContent';
import { bannerContentDisplaySwitchFeatures, bannerContentFeatures } from '@test/features/BannerContent';
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearly_CustomAmount';
import { useFormModel } from '@src/components/composables/useFormModel';
import { resetFormModel } from '@test/resetFormModel';
import { DynamicContent } from '@src/utils/DynamicContent/DynamicContent';

const formModel = useFormModel();
const translator = ( key: string ): string => key;
Expand All @@ -23,7 +24,7 @@ describe( 'BannerCtrl.vue', () => {
resetFormModel( formModel );
} );

const getWrapper = (): VueWrapper<any> => {
const getWrapper = ( dynamicContent: DynamicContent|null = null ): VueWrapper<any> => {
return mount( Banner, {
props: {
bannerState: BannerStates.Pending,
Expand All @@ -35,7 +36,7 @@ describe( 'BannerCtrl.vue', () => {
},
provide: {
translator: { translate: translator },
dynamicCampaignText: dynamicCampaignContent,
dynamicCampaignText: dynamicContent ?? dynamicCampaignContent,
formActions: { donateWithAddressAction: 'https://example.com', donateWithoutAddressAction: 'https://example.com' },
currencyFormatter: new CurrencyEn(),
formItems,
Expand All @@ -50,14 +51,14 @@ describe( 'BannerCtrl.vue', () => {
[ 'expectSlideShowPlaysWhenBecomesVisible' ],
[ 'expectSlideShowStopsOnFormInteraction' ]
] )( '%s', async ( testName: string ) => {
await desktopContentFeatures[ testName ]( getWrapper() );
await bannerContentFeatures[ testName ]( getWrapper() );
} );

test.each( [
[ 'expectShowsSlideShowOnSmallSizes' ],
[ 'expectShowsMessageOnSmallSizes' ]
] )( '%s', async ( testName: string ) => {
await desktopContentDisplaySwitchFeatures[ testName ]( getWrapper );
await bannerContentDisplaySwitchFeatures[ testName ]( getWrapper );
} );
} );

Expand Down
6 changes: 3 additions & 3 deletions test/banners/desktop/components/BannerVar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn';
import { TrackerStub } from '@test/fixtures/TrackerStub';
import { softCloseFeatures } from '@test/features/SoftCloseDesktop';
import { useOfFundsFeatures } from '@test/features/UseOfFunds';
import { desktopContentDisplaySwitchFeatures, desktopContentFeatures } from '@test/features/DesktopContent';
import { bannerContentDisplaySwitchFeatures, bannerContentFeatures } from '@test/features/BannerContent';
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearly_CustomAmount_AddressType';
import { useFormModel } from '@src/components/composables/useFormModel';
import { resetFormModel } from '@test/resetFormModel';
Expand Down Expand Up @@ -50,14 +50,14 @@ describe( 'BannerVar.vue', () => {
[ 'expectSlideShowPlaysWhenBecomesVisible' ],
[ 'expectSlideShowStopsOnFormInteraction' ]
] )( '%s', async ( testName: string ) => {
await desktopContentFeatures[ testName ]( getWrapper() );
await bannerContentFeatures[ testName ]( getWrapper() );
} );

test.each( [
[ 'expectShowsSlideShowOnSmallSizes' ],
[ 'expectShowsMessageOnSmallSizes' ]
] )( '%s', async ( testName: string ) => {
await desktopContentDisplaySwitchFeatures[ testName ]( getWrapper );
await bannerContentDisplaySwitchFeatures[ testName ]( getWrapper );
} );
} );

Expand Down
6 changes: 3 additions & 3 deletions test/banners/english/components/BannerCtrl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { formItems } from '@test/banners/formItems';
import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn';
import { softCloseFeatures } from '@test/features/SoftCloseDesktop';
import { useOfFundsFeatures } from '@test/features/UseOfFunds';
import { desktopContentDisplaySwitchFeatures, desktopContentFeatures } from '@test/features/DesktopContent';
import { bannerContentDisplaySwitchFeatures, bannerContentFeatures } from '@test/features/BannerContent';
import { TrackerStub } from '@test/fixtures/TrackerStub';
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearly_CustomAmount';
import { useFormModel } from '@src/components/composables/useFormModel';
Expand Down Expand Up @@ -50,14 +50,14 @@ describe( 'BannerCtrl.vue', () => {
[ 'expectSlideShowPlaysWhenBecomesVisible' ],
[ 'expectSlideShowStopsOnFormInteraction' ]
] )( '%s', async ( testName: string ) => {
await desktopContentFeatures[ testName ]( getWrapper() );
await bannerContentFeatures[ testName ]( getWrapper() );
} );

test.each( [
[ 'expectShowsSlideShowOnSmallSizes' ],
[ 'expectShowsMessageOnSmallSizes' ]
] )( '%s', async ( testName: string ) => {
await desktopContentDisplaySwitchFeatures[ testName ]( getWrapper );
await bannerContentDisplaySwitchFeatures[ testName ]( getWrapper );
} );
} );

Expand Down
6 changes: 3 additions & 3 deletions test/banners/english/components/BannerVar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { formItems } from '@test/banners/formItems';
import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn';
import { softCloseFeatures } from '@test/features/SoftCloseDesktop';
import { useOfFundsFeatures } from '@test/features/UseOfFunds';
import { desktopContentDisplaySwitchFeatures, desktopContentFeatures } from '@test/features/DesktopContent';
import { bannerContentDisplaySwitchFeatures, bannerContentFeatures } from '@test/features/BannerContent';
import { alreadyDonatedModalFeatures } from '@test/features/AlreadyDonatedModal';
import { TrackerStub } from '@test/fixtures/TrackerStub';
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearly_CustomAmount';
Expand Down Expand Up @@ -51,14 +51,14 @@ describe( 'BannerVar.vue', () => {
[ 'expectSlideShowPlaysWhenBecomesVisible' ],
[ 'expectSlideShowStopsOnFormInteraction' ]
] )( '%s', async ( testName: string ) => {
await desktopContentFeatures[ testName ]( getWrapper() );
await bannerContentFeatures[ testName ]( getWrapper() );
} );

test.each( [
[ 'expectShowsSlideShowOnSmallSizes' ],
[ 'expectShowsMessageOnSmallSizes' ]
] )( '%s', async ( testName: string ) => {
await desktopContentDisplaySwitchFeatures[ testName ]( getWrapper );
await bannerContentDisplaySwitchFeatures[ testName ]( getWrapper );
} );
} );

Expand Down
4 changes: 2 additions & 2 deletions test/banners/pad/components/BannerCtrl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn';
import { TrackerStub } from '@test/fixtures/TrackerStub';
import { softCloseFeatures } from '@test/features/SoftCloseDesktop';
import { useOfFundsFeatures } from '@test/features/UseOfFunds';
import { desktopContentFeatures } from '@test/features/DesktopContent';
import { bannerContentFeatures } from '@test/features/BannerContent';
import { alreadyDonatedModalFeatures } from '@test/features/AlreadyDonatedModal';
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearlyButton';
import { useFormModel } from '@src/components/composables/useFormModel';
Expand Down Expand Up @@ -57,7 +57,7 @@ describe( 'BannerCtrl.vue', () => {
[ 'expectSlideShowPlaysWhenBecomesVisible' ],
[ 'expectSlideShowStopsOnFormInteraction' ]
] )( '%s', async ( testName: string ) => {
await desktopContentFeatures[ testName ]( wrapper );
await bannerContentFeatures[ testName ]( wrapper );
} );
} );

Expand Down
4 changes: 2 additions & 2 deletions test/banners/pad/components/BannerVar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn';
import { TrackerStub } from '@test/fixtures/TrackerStub';
import { softCloseFeatures } from '@test/features/SoftCloseDesktop';
import { useOfFundsFeatures } from '@test/features/UseOfFunds';
import { desktopContentFeatures } from '@test/features/DesktopContent';
import { bannerContentFeatures } from '@test/features/BannerContent';
import { alreadyDonatedModalFeatures } from '@test/features/AlreadyDonatedModal';
import { resetFormModel } from '@test/resetFormModel';
import { useFormModel } from '@src/components/composables/useFormModel';
Expand Down Expand Up @@ -56,7 +56,7 @@ describe( 'BannerVar.vue', () => {
[ 'expectSlideShowPlaysWhenBecomesVisible' ],
[ 'expectSlideShowStopsOnFormInteraction' ]
] )( '%s', async ( testName: string ) => {
await desktopContentFeatures[ testName ]( wrapper );
await bannerContentFeatures[ testName ]( wrapper );
} );
} );

Expand Down
4 changes: 2 additions & 2 deletions test/banners/pad_english/components/BannerCtrl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn';
import { formItems } from '@test/banners/formItems';
import { TrackerStub } from '@test/fixtures/TrackerStub';
import { useOfFundsFeatures } from '@test/features/UseOfFunds';
import { desktopContentFeatures } from '@test/features/DesktopContent';
import { bannerContentFeatures } from '@test/features/BannerContent';
import { resetFormModel } from '@test/resetFormModel';
import { useFormModel } from '@src/components/composables/useFormModel';
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearlyButton_CustomAmount';
Expand Down Expand Up @@ -54,7 +54,7 @@ describe( 'BannerCtrl.vue', () => {
[ 'expectSlideShowPlaysWhenBecomesVisible' ],
[ 'expectSlideShowStopsOnFormInteraction' ]
] )( '%s', async ( testName: string ) => {
await desktopContentFeatures[ testName ]( wrapper );
await bannerContentFeatures[ testName ]( wrapper );
} );
} );

Expand Down
4 changes: 2 additions & 2 deletions test/banners/pad_english/components/BannerVar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn';
import { formItems } from '@test/banners/formItems';
import { TrackerStub } from '@test/fixtures/TrackerStub';
import { useOfFundsFeatures } from '@test/features/UseOfFunds';
import { desktopContentFeatures } from '@test/features/DesktopContent';
import { bannerContentFeatures } from '@test/features/BannerContent';
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearlyButton_CustomAmount';
import { useFormModel } from '@src/components/composables/useFormModel';
import { resetFormModel } from '@test/resetFormModel';
Expand Down Expand Up @@ -54,7 +54,7 @@ describe( 'BannerVar.vue', () => {
[ 'expectSlideShowPlaysWhenBecomesVisible' ],
[ 'expectSlideShowStopsOnFormInteraction' ]
] )( '%s', async ( testName: string ) => {
await desktopContentFeatures[ testName ]( wrapper );
await bannerContentFeatures[ testName ]( wrapper );
} );
} );

Expand Down
6 changes: 3 additions & 3 deletions test/banners/wpde_desktop/components/BannerCtrl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useOfFundsContent } from '@test/banners/useOfFundsContent';
import { formItems } from '@test/banners/formItems';
import { CurrencyEn } from '@src/utils/DynamicContent/formatters/CurrencyEn';
import { useOfFundsFeatures } from '@test/features/UseOfFunds';
import { desktopContentDisplaySwitchFeatures, desktopContentFeatures } from '@test/features/DesktopContent';
import { bannerContentDisplaySwitchFeatures, bannerContentFeatures } from '@test/features/BannerContent';
import { TrackerStub } from '@test/fixtures/TrackerStub';
import { donationFormFeatures } from '@test/features/forms/MainDonation_UpgradeToYearly_CustomAmount';
import { useFormModel } from '@src/components/composables/useFormModel';
Expand Down Expand Up @@ -49,14 +49,14 @@ describe( 'BannerCtrl.vue', () => {
[ 'expectSlideShowPlaysWhenBecomesVisible' ],
[ 'expectSlideShowStopsOnFormInteraction' ]
] )( '%s', async ( testName: string ) => {
await desktopContentFeatures[ testName ]( getWrapper() );
await bannerContentFeatures[ testName ]( getWrapper() );
} );

test.each( [
[ 'expectShowsSlideShowOnSmallSizes' ],
[ 'expectShowsMessageOnSmallSizes' ]
] )( '%s', async ( testName: string ) => {
await desktopContentDisplaySwitchFeatures[ testName ]( getWrapper );
await bannerContentDisplaySwitchFeatures[ testName ]( getWrapper );
} );
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ const expectShowsMessageOnSmallSizes = async ( getWrapper: () => VueWrapper<any>
expect( wrapper.find( '.wmde-banner-message' ).exists() ).toBeTruthy();
};

export const desktopContentFeatures: Record<string, ( wrapper: VueWrapper<any> ) => Promise<any>> = {
export const bannerContentFeatures: Record<string, ( wrapper: VueWrapper<any> ) => Promise<any>> = {
expectSlideShowPlaysWhenBecomesVisible,
expectSlideShowStopsOnFormInteraction
};

export const desktopContentDisplaySwitchFeatures: Record<string, ( getWrapper: () => VueWrapper<any> ) => Promise<any>> = {
export const bannerContentDisplaySwitchFeatures: Record<string, ( getWrapper: () => VueWrapper<any> ) => Promise<any>> = {
expectShowsSlideShowOnSmallSizes,
expectShowsMessageOnSmallSizes
};

0 comments on commit 8c7ac6c

Please sign in to comment.