unit tests
This commit is contained in:
parent
7651441115
commit
844d1b0215
2 changed files with 108 additions and 4 deletions
|
|
@ -12,10 +12,18 @@ import { createTestingPinia } from '@pinia/testing';
|
||||||
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
|
||||||
|
|
||||||
jest.mock('@/helpers/cms-content-helper', () => ({
|
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
fetchCmsContentForPage: jest.fn()
|
fetchCmsContentForPage: jest.fn(),
|
||||||
|
processIfStatements: jest.fn()
|
||||||
}));
|
}));
|
||||||
const wordingText = 'wording Text {custom:address}';
|
const wordingText = 'wording Text {custom:address}';
|
||||||
|
|
||||||
|
const inShopDuration = '60-90 minutes';
|
||||||
|
jest.mock('@/helpers/date-helper', () => ({
|
||||||
|
getDisplayTextForDurationLength: jest.fn().mockImplementation(() => inShopDuration),
|
||||||
|
convertDateStringToDate: jest.fn(),
|
||||||
|
get12HourTimeFormat: jest.fn()
|
||||||
|
}));
|
||||||
|
|
||||||
const mockMixin = {
|
const mockMixin = {
|
||||||
methods: {
|
methods: {
|
||||||
getCmsContent: jest.fn().mockImplementation(() => wordingText),
|
getCmsContent: jest.fn().mockImplementation(() => wordingText),
|
||||||
|
|
@ -34,12 +42,18 @@ const headerStub = {
|
||||||
render: () => {}
|
render: () => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const vehicleBannerStub = {
|
||||||
|
render: () => {}
|
||||||
|
};
|
||||||
|
|
||||||
const initialStore = {
|
const initialStore = {
|
||||||
order: {
|
order: {
|
||||||
schedule: {
|
schedule: {
|
||||||
date: '2024-03-01',
|
date: '2024-03-01',
|
||||||
startTime: '09:00',
|
startTime: '09:00',
|
||||||
endTime: '10:00'
|
endTime: '10:00',
|
||||||
|
jobMinMinutes: 60,
|
||||||
|
jobMaxMinutes: 90
|
||||||
},
|
},
|
||||||
serviceLocation: {
|
serviceLocation: {
|
||||||
address: '123 Test Way',
|
address: '123 Test Way',
|
||||||
|
|
@ -70,7 +84,8 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
|
||||||
|
|
||||||
mountOptions.global.stubs = {
|
mountOptions.global.stubs = {
|
||||||
siteFooter: footerStub,
|
siteFooter: footerStub,
|
||||||
siteHeader: headerStub
|
siteHeader: headerStub,
|
||||||
|
vehicleBanner: vehicleBannerStub
|
||||||
};
|
};
|
||||||
|
|
||||||
const testingPinia = createTestingPinia({
|
const testingPinia = createTestingPinia({
|
||||||
|
|
@ -110,6 +125,16 @@ describe('OrderConfirmation.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(siteHeader.exists()).toBe(true);
|
expect(siteHeader.exists()).toBe(true);
|
||||||
});
|
});
|
||||||
|
test('Should render Vehicle Banner', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(initialStore);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const vehicleBanner = wrapper.findComponent(vehicleBannerStub);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(vehicleBanner.exists()).toBe(true);
|
||||||
|
});
|
||||||
test('If Advanced flow, should display Site Footer', () => {
|
test('If Advanced flow, should display Site Footer', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const testStore = {
|
const testStore = {
|
||||||
|
|
@ -324,5 +349,84 @@ describe('OrderConfirmation.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual('<br/>123 Safelite Street,<br/> Mesa, AZ 12345<br/>');
|
expect(testValue).toEqual('<br/>123 Safelite Street,<br/> Mesa, AZ 12345<br/>');
|
||||||
});
|
});
|
||||||
|
test('appointmentWordingText2 should return Mobile text in expected format', () => {
|
||||||
|
// Arrange
|
||||||
|
const testStore = {
|
||||||
|
order: {
|
||||||
|
schedule: {
|
||||||
|
date: '2019-01-01',
|
||||||
|
startTime: '09:00',
|
||||||
|
endTime: '10:00'
|
||||||
|
},
|
||||||
|
serviceLocation: {
|
||||||
|
address: '123 Test Way',
|
||||||
|
address2: '#1',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345',
|
||||||
|
appointmentType: 'Mobile'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(testStore);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.appointmentWordingText2;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual(wordingText);
|
||||||
|
});
|
||||||
|
test('appointmentWordingText2 should return Drop Off and text in expected format', () => {
|
||||||
|
// Arrange
|
||||||
|
const testStore = {
|
||||||
|
order: {
|
||||||
|
schedule: {
|
||||||
|
date: '2019-01-01',
|
||||||
|
startTime: '09:00',
|
||||||
|
endTime: '10:00'
|
||||||
|
},
|
||||||
|
serviceLocation: {
|
||||||
|
provider: {
|
||||||
|
address: {
|
||||||
|
streetAddress: '123 Safelite Street',
|
||||||
|
city: 'Mesa',
|
||||||
|
state: 'AZ',
|
||||||
|
zipCode: '12345'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
appointmentType: 'Drop Off'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(testStore);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.appointmentWordingText2;
|
||||||
|
const expected = wrapper.vm.getBodyText2FromCms('Test Widget');
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual(expected);
|
||||||
|
});
|
||||||
|
test('appointmentWordingText2 should return In Shop text in expected format', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(initialStore);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.appointmentWordingText2;
|
||||||
|
const expected = wrapper.vm.getBodyText2FromCms('Test Widget');
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual(expected);
|
||||||
|
});
|
||||||
|
test('inShopAppointmentDuration should return appointment length', () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = getMountedComponent(initialStore);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.inShopAppointmentDuration;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual(inShopDuration);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ export default {
|
||||||
// This conversion ensures we don't get get GMT induced date changes
|
// This conversion ensures we don't get get GMT induced date changes
|
||||||
const dateObject = convertDateStringToDate(this.appointmentDate);
|
const dateObject = convertDateStringToDate(this.appointmentDate);
|
||||||
// Ex: Tuesday, April 22
|
// Ex: Tuesday, April 22
|
||||||
return dateObject.toLocaleDateString('en-us', {
|
return dateObject?.toLocaleDateString('en-us', {
|
||||||
weekday: 'long',
|
weekday: 'long',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
day: 'numeric'
|
day: 'numeric'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue