INSR-10489: Add tests for state-specific text on payment-method

This commit is contained in:
Alex Humphries 2026-07-24 23:14:29 -04:00
parent 1f7e5f10ec
commit 79894f18f7
2 changed files with 29 additions and 2 deletions

View file

@ -20,7 +20,7 @@ jest.mock('@/helpers/order-helper.js', () => ({
saveSession: jest.fn() saveSession: jest.fn()
})); }));
function setupMocks({ customMountOptions = {}, queryString }, mainInitialState = {}, customMixin = null) { function setupMocks({ customMountOptions = {}, queryString }, mainInitialState = {}, customMixin = null, mockCmsContent = '') {
const mountOptions = getMountOptions({ const mountOptions = getMountOptions({
...customMountOptions, ...customMountOptions,
route: { query: { issPage: issPageValues.PAYMENT_METHOD, ...queryString }, params: {} }, route: { query: { issPage: issPageValues.PAYMENT_METHOD, ...queryString }, params: {} },
@ -51,7 +51,9 @@ function setupMocks({ customMountOptions = {}, queryString }, mainInitialState =
}; };
const cmsMixin = { const cmsMixin = {
methods: { methods: {
getCmsContent: jest.fn() getCmsContent: jest.fn((widget, field) => {
return mockCmsContent;
})
} }
} }
@ -320,4 +322,28 @@ describe('payment-method.vue', () => {
expect(submitWorkOrder).toHaveBeenCalledTimes(1); expect(submitWorkOrder).toHaveBeenCalledTimes(1);
}); });
}); });
describe('State Specific Text Rendering', () => {
test('State specific textBlock component exists when CMS content for it exists', () => {
// Arrange
const mockCmsContent = 'This is a test CMS content for state specific text.';
const wrapper = setupMocks({}, {}, null, mockCmsContent);
// Act
const stateSpecificTextBlock = wrapper.find('[class="state-specific-text"]');
// Assert
expect(stateSpecificTextBlock.exists()).toBe(true);
});
test('State specific textBlock component does not exist when CMS content for it does not exist', () => {
// Arrange
const wrapper = setupMocks({}, {}, null, '');
// Act
const stateSpecificTextBlock = wrapper.find('[class="state-specific-text"]');
// Assert
expect(stateSpecificTextBlock.exists()).toBe(false);
});
});
}); });

View file

@ -21,6 +21,7 @@
cmsWidgetName="SiteSubHeaderWidget" /> cmsWidgetName="SiteSubHeaderWidget" />
<textBlock <textBlock
v-if="stateSpecificText" v-if="stateSpecificText"
class="state-specific-text"
:customText="stateSpecificText" /> :customText="stateSpecificText" />
<div class="main-content-container"> <div class="main-content-container">
<hr class="section-divider" /> <hr class="section-divider" />