Updating damage review tests
This commit is contained in:
parent
5121c70bcc
commit
a84c0081c8
2 changed files with 446 additions and 393 deletions
411
src/helpers/damage-review-content-generator.spec.js
Normal file
411
src/helpers/damage-review-content-generator.spec.js
Normal file
|
|
@ -0,0 +1,411 @@
|
|||
import { getDamageDisplayContent, getLocationAnswer } from '@/helpers/damage-review-content-generator.js';
|
||||
import damageLocationsSelected from '@/constants/damage-locations-selected';
|
||||
|
||||
const testConstants = {
|
||||
cmsConstants: {
|
||||
widgetNames: {
|
||||
locations: 'DamageLocationsWidget',
|
||||
driverDamages: 'DriverDamagesWidget',
|
||||
passengerDamages: 'PassengerDamagesWidget'
|
||||
},
|
||||
damageLocations: {
|
||||
windshield: damageLocationsSelected.WINDSHIELD,
|
||||
driver: damageLocationsSelected.DRIVER,
|
||||
passenger: damageLocationsSelected.PASSENGER,
|
||||
rear: damageLocationsSelected.REAR
|
||||
},
|
||||
damageNames: {
|
||||
vent: damageLocationsSelected.VENT,
|
||||
front: damageLocationsSelected.FRONT,
|
||||
back: damageLocationsSelected.BACK,
|
||||
quarter: damageLocationsSelected.QUARTER,
|
||||
side: damageLocationsSelected.SIDEDOOR
|
||||
},
|
||||
locationCopy: {
|
||||
windshield: 'Windshield copy',
|
||||
driver: 'Driver copy',
|
||||
passenger: 'Passenger copy',
|
||||
rear: 'Rear copy'
|
||||
},
|
||||
damageCopy: {
|
||||
vent: 'Vent copy',
|
||||
front: 'Front copy',
|
||||
back: 'Back copy',
|
||||
quarter: 'Quarter copy',
|
||||
side: 'Side copy'
|
||||
},
|
||||
imageId: '00000000-0000-0000-0000-000000000000'
|
||||
},
|
||||
glassItems: {
|
||||
windshield: {
|
||||
glassLocation: damageLocationsSelected.WINDSHIELD,
|
||||
glassName: damageLocationsSelected.SINGLE
|
||||
},
|
||||
rear: {
|
||||
glassLocation: damageLocationsSelected.REAR,
|
||||
glassName: damageLocationsSelected.STATIONARY
|
||||
},
|
||||
passengerItems: {
|
||||
vent: {
|
||||
glassLocation: damageLocationsSelected.PASSENGER,
|
||||
glassName: damageLocationsSelected.VENT
|
||||
},
|
||||
front: {
|
||||
glassLocation: damageLocationsSelected.PASSENGER,
|
||||
glassName: damageLocationsSelected.FRONT
|
||||
},
|
||||
back: {
|
||||
glassLocation: damageLocationsSelected.PASSENGER,
|
||||
glassName: damageLocationsSelected.BACK
|
||||
},
|
||||
quarter: {
|
||||
glassLocation: damageLocationsSelected.PASSENGER,
|
||||
glassName: damageLocationsSelected.QUARTER
|
||||
},
|
||||
side: {
|
||||
glassLocation: damageLocationsSelected.PASSENGER,
|
||||
glassName: damageLocationsSelected.SIDEDOOR
|
||||
}
|
||||
},
|
||||
driverItems: {
|
||||
vent: {
|
||||
glassLocation: damageLocationsSelected.DRIVER,
|
||||
glassName: damageLocationsSelected.VENT
|
||||
},
|
||||
front: {
|
||||
glassLocation: damageLocationsSelected.DRIVER,
|
||||
glassName: damageLocationsSelected.FRONT
|
||||
},
|
||||
back: {
|
||||
glassLocation: damageLocationsSelected.DRIVER,
|
||||
glassName: damageLocationsSelected.BACK
|
||||
},
|
||||
quarter: {
|
||||
glassLocation: damageLocationsSelected.DRIVER,
|
||||
glassName: damageLocationsSelected.QUARTER
|
||||
},
|
||||
side: {
|
||||
glassLocation: damageLocationsSelected.DRIVER,
|
||||
glassName: damageLocationsSelected.SIDEDOOR
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const cmsContent = {
|
||||
DamageLocationsWidget: {
|
||||
Answers: [
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageLocations.windshield,
|
||||
Text: testConstants.cmsConstants.locationCopy.windshield,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageLocations.driver,
|
||||
Text: testConstants.cmsConstants.locationCopy.driver,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: testConstants.cmsConstants.widgetNames.driverDamages
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageLocations.passenger,
|
||||
Text: testConstants.cmsConstants.locationCopy.passenger,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: testConstants.cmsConstants.widgetNames.passengerDamages
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageLocations.rear,
|
||||
Text: testConstants.cmsConstants.locationCopy.rear,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
}
|
||||
]
|
||||
},
|
||||
DriverDamagesWidget: {
|
||||
Answers: [
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.vent,
|
||||
Text: testConstants.cmsConstants.damageCopy.vent,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.front,
|
||||
Text: testConstants.cmsConstants.damageCopy.front,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.back,
|
||||
Text: testConstants.cmsConstants.damageCopy.back,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.quarter,
|
||||
Text: testConstants.cmsConstants.damageCopy.quarter,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.side,
|
||||
Text: testConstants.cmsConstants.damageCopy.side,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
}
|
||||
]
|
||||
},
|
||||
PassengerDamagesWidget: {
|
||||
Answers: [
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.vent,
|
||||
Text: testConstants.cmsConstants.damageCopy.vent,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.front,
|
||||
Text: testConstants.cmsConstants.damageCopy.front,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.back,
|
||||
Text: testConstants.cmsConstants.damageCopy.back,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.quarter,
|
||||
Text: testConstants.cmsConstants.damageCopy.quarter,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.side,
|
||||
Text: testConstants.cmsConstants.damageCopy.side,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
describe('damage-review-content-generator', () => {
|
||||
describe('getLocationAnswer', () => {
|
||||
test('answer with damage location name match', () => {
|
||||
// Arrange
|
||||
const damageLocation = 'matching name';
|
||||
const expected = { Name: damageLocation };
|
||||
const locationAnswers = [{ Name: 'non matching name' }, expected];
|
||||
|
||||
// Act
|
||||
const result = getLocationAnswer(damageLocation, locationAnswers);
|
||||
|
||||
// Assert
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
test('no damage location name match', () => {
|
||||
// Arrange
|
||||
const damageLocation = 'random string';
|
||||
const locationAnswers = [{ Name: 'non matching name' }];
|
||||
|
||||
// Act
|
||||
const result = getLocationAnswer(damageLocation, locationAnswers);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(undefined);
|
||||
});
|
||||
test.each([
|
||||
[[]],
|
||||
[null],
|
||||
[undefined]
|
||||
])('location answers %p', (locationAnswers) => {
|
||||
// Arrange
|
||||
const damageLocation = 'some string';
|
||||
|
||||
// Act
|
||||
const result = getLocationAnswer(damageLocation, locationAnswers);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(undefined);
|
||||
});
|
||||
});
|
||||
describe('Correctly assembles damage info into a display string', () => {
|
||||
const locationAnswers = cmsContent.DamageLocationsWidget.Answers;
|
||||
test('Shows windshield copy when windshield damage is included', async () => {
|
||||
// Arrange
|
||||
const glassToReplace = [testConstants.glassItems.windshield];
|
||||
const isRepair = false;
|
||||
|
||||
// Act
|
||||
const result = getDamageDisplayContent(locationAnswers, null, null, glassToReplace, isRepair);
|
||||
|
||||
// Assert
|
||||
expect(result).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.windshield
|
||||
]);
|
||||
});
|
||||
|
||||
test('Windshield copy is shown when order is a repair', async () => {
|
||||
// Arrange
|
||||
const glassToReplace = [];
|
||||
const isRepair = true;
|
||||
|
||||
// Act
|
||||
const result = getDamageDisplayContent(locationAnswers, null, null, glassToReplace, isRepair);
|
||||
|
||||
// Assert
|
||||
expect(result).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.windshield
|
||||
]);
|
||||
});
|
||||
|
||||
test('Rear windshield copy shows when rear damage is present', async () => {
|
||||
// Arrange
|
||||
const glassToReplace = [testConstants.glassItems.rear];
|
||||
const isRepair = false;
|
||||
|
||||
// Act
|
||||
const result = getDamageDisplayContent(locationAnswers, null, null, glassToReplace, isRepair);
|
||||
|
||||
// Assert
|
||||
expect(result).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.rear
|
||||
]);
|
||||
});
|
||||
|
||||
test('Driver side copy and items are shown when driver side damage is present', async () => {
|
||||
// Arrange
|
||||
const driverSideDamageAnswers = cmsContent.DriverDamagesWidget.Answers;
|
||||
const glassToReplace = [
|
||||
testConstants.glassItems.driverItems.back,
|
||||
testConstants.glassItems.driverItems.front
|
||||
];
|
||||
const isRepair = false;
|
||||
const expectedList = '<ul>'
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.front}</li>`
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.back}</li>`
|
||||
+ '</ul>';
|
||||
|
||||
// Act
|
||||
const result = getDamageDisplayContent(
|
||||
locationAnswers,
|
||||
driverSideDamageAnswers,
|
||||
null,
|
||||
glassToReplace,
|
||||
isRepair
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(result).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.driver,
|
||||
expectedList
|
||||
]);
|
||||
});
|
||||
|
||||
test('Passenger side copy and items are shown when passenger side damage is present', async () => {
|
||||
// Arrange
|
||||
const passengerSideDamageAnswers = cmsContent.PassengerDamagesWidget.Answers;
|
||||
const glassToReplace = [
|
||||
testConstants.glassItems.passengerItems.quarter,
|
||||
testConstants.glassItems.passengerItems.vent,
|
||||
testConstants.glassItems.passengerItems.side
|
||||
];
|
||||
const isRepair = false;
|
||||
const expectedList = '<ul>'
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.vent}</li>`
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.quarter}</li>`
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.side}</li>`
|
||||
+ '</ul>';
|
||||
|
||||
// Act
|
||||
const result = getDamageDisplayContent(
|
||||
locationAnswers,
|
||||
null,
|
||||
passengerSideDamageAnswers,
|
||||
glassToReplace,
|
||||
isRepair
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(result).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.passenger,
|
||||
expectedList
|
||||
]);
|
||||
});
|
||||
|
||||
test('All relevant sections are shown in order in multiglass scenario', async () => {
|
||||
// Arrange
|
||||
const driverSideDamageAnswers = cmsContent.DriverDamagesWidget.Answers;
|
||||
const passengerSideDamageAnswers = cmsContent.PassengerDamagesWidget.Answers;
|
||||
const glassToReplace = [
|
||||
testConstants.glassItems.windshield,
|
||||
testConstants.glassItems.rear,
|
||||
testConstants.glassItems.driverItems.vent,
|
||||
testConstants.glassItems.driverItems.front,
|
||||
testConstants.glassItems.driverItems.back,
|
||||
testConstants.glassItems.passengerItems.quarter,
|
||||
testConstants.glassItems.passengerItems.back,
|
||||
testConstants.glassItems.passengerItems.side
|
||||
];
|
||||
const isRepair = false;
|
||||
const expectedDriverDamageList = '<ul>'
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.vent}</li>`
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.front}</li>`
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.back}</li>`
|
||||
+ '</ul>';
|
||||
const expectedPassengerDamageList = '<ul>'
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.back}</li>`
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.quarter}</li>`
|
||||
+ `<li>${testConstants.cmsConstants.damageCopy.side}</li>`
|
||||
+ '</ul>';
|
||||
|
||||
// Act
|
||||
const result = getDamageDisplayContent(
|
||||
locationAnswers,
|
||||
driverSideDamageAnswers,
|
||||
passengerSideDamageAnswers,
|
||||
glassToReplace,
|
||||
isRepair
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(result).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.windshield,
|
||||
testConstants.cmsConstants.locationCopy.driver,
|
||||
expectedDriverDamageList,
|
||||
testConstants.cmsConstants.locationCopy.passenger,
|
||||
expectedPassengerDamageList,
|
||||
testConstants.cmsConstants.locationCopy.rear
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -2,113 +2,16 @@
|
|||
import damageReview from '@/layouts/payment-method/review-dropdown/review-sections/damage-review/damage-review.vue';
|
||||
|
||||
// Supporting Files
|
||||
import { createTestingPinia } from '@pinia/testing';
|
||||
import { useMainStore } from '@/store';
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import damageLocationsSelected from '@/constants/damage-locations-selected';
|
||||
import { getDamageDisplayContent } from '@/helpers/damage-review-content-generator.js';
|
||||
|
||||
const testConstants = {
|
||||
cmsConstants: {
|
||||
widgetNames: {
|
||||
header: 'DamageReviewWidget',
|
||||
locations: 'DamageLocationsWidget',
|
||||
driverDamages: 'DriverDamagesWidget',
|
||||
passengerDamages: 'PassengerDamagesWidget'
|
||||
},
|
||||
header: {
|
||||
text: 'Damage'
|
||||
},
|
||||
damageLocations: {
|
||||
windshield: damageLocationsSelected.WINDSHIELD,
|
||||
driver: damageLocationsSelected.DRIVER,
|
||||
passenger: damageLocationsSelected.PASSENGER,
|
||||
rear: damageLocationsSelected.REAR
|
||||
},
|
||||
damageNames: {
|
||||
vent: damageLocationsSelected.VENT,
|
||||
front: damageLocationsSelected.FRONT,
|
||||
back: damageLocationsSelected.BACK,
|
||||
quarter: damageLocationsSelected.QUARTER,
|
||||
side: damageLocationsSelected.SIDEDOOR
|
||||
},
|
||||
locationCopy: {
|
||||
windshield: 'Windshield copy',
|
||||
driver: 'Driver copy',
|
||||
passenger: 'Passenger copy',
|
||||
rear: 'Rear copy'
|
||||
},
|
||||
damageCopy: {
|
||||
vent: 'Vent copy',
|
||||
front: 'Front copy',
|
||||
back: 'Back copy',
|
||||
quarter: 'Quarter copy',
|
||||
side: 'Side copy'
|
||||
},
|
||||
imageId: '00000000-0000-0000-0000-000000000000'
|
||||
},
|
||||
makeBulletedList: (items) => {
|
||||
let list = '<ul>';
|
||||
items.forEach((item) => {
|
||||
list += `<li>${item}</li>`;
|
||||
});
|
||||
list += '</ul>';
|
||||
|
||||
return list;
|
||||
},
|
||||
glassItems: {
|
||||
windshield: {
|
||||
glassLocation: damageLocationsSelected.WINDSHIELD,
|
||||
glassName: damageLocationsSelected.SINGLE
|
||||
},
|
||||
rear: {
|
||||
glassLocation: damageLocationsSelected.REAR,
|
||||
glassName: damageLocationsSelected.STATIONARY
|
||||
},
|
||||
passengerItems: {
|
||||
vent: {
|
||||
glassLocation: damageLocationsSelected.PASSENGER,
|
||||
glassName: damageLocationsSelected.VENT
|
||||
},
|
||||
front: {
|
||||
glassLocation: damageLocationsSelected.PASSENGER,
|
||||
glassName: damageLocationsSelected.FRONT
|
||||
},
|
||||
back: {
|
||||
glassLocation: damageLocationsSelected.PASSENGER,
|
||||
glassName: damageLocationsSelected.BACK
|
||||
},
|
||||
quarter: {
|
||||
glassLocation: damageLocationsSelected.PASSENGER,
|
||||
glassName: damageLocationsSelected.QUARTER
|
||||
},
|
||||
side: {
|
||||
glassLocation: damageLocationsSelected.PASSENGER,
|
||||
glassName: damageLocationsSelected.SIDEDOOR
|
||||
}
|
||||
},
|
||||
driverItems: {
|
||||
vent: {
|
||||
glassLocation: damageLocationsSelected.DRIVER,
|
||||
glassName: damageLocationsSelected.VENT
|
||||
},
|
||||
front: {
|
||||
glassLocation: damageLocationsSelected.DRIVER,
|
||||
glassName: damageLocationsSelected.FRONT
|
||||
},
|
||||
back: {
|
||||
glassLocation: damageLocationsSelected.DRIVER,
|
||||
glassName: damageLocationsSelected.BACK
|
||||
},
|
||||
quarter: {
|
||||
glassLocation: damageLocationsSelected.DRIVER,
|
||||
glassName: damageLocationsSelected.QUARTER
|
||||
},
|
||||
side: {
|
||||
glassLocation: damageLocationsSelected.DRIVER,
|
||||
glassName: damageLocationsSelected.SIDEDOOR
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
jest.mock('@/helpers/damage-review-content-generator.js', () => ({
|
||||
getDamageDisplayContent: jest.fn(),
|
||||
getLocationAnswer: jest.fn()
|
||||
}));
|
||||
|
||||
let cmsContent;
|
||||
const mockMixin = {
|
||||
|
|
@ -117,15 +20,22 @@ const mockMixin = {
|
|||
}
|
||||
};
|
||||
|
||||
function getShallowMountedComponent(initialData = {}, methodToRun = () => {}) {
|
||||
function getShallowMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}) {
|
||||
const mountOptions = getMountOptions({
|
||||
router: {
|
||||
navigate: jest.fn()
|
||||
}
|
||||
});
|
||||
|
||||
const testingPinia = createTestingPinia({
|
||||
initialState: {
|
||||
main: mainInitialState
|
||||
}
|
||||
});
|
||||
useMainStore(testingPinia);
|
||||
methodToRun();
|
||||
|
||||
mountOptions.global.plugins = [testingPinia];
|
||||
mountOptions.data = () => (
|
||||
initialData
|
||||
);
|
||||
|
|
@ -137,300 +47,32 @@ function getShallowMountedComponent(initialData = {}, methodToRun = () => {}) {
|
|||
}
|
||||
|
||||
beforeEach(() => {
|
||||
cmsContent = {
|
||||
DamageReviewWidget: {
|
||||
Text: testConstants.cmsConstants.header.text
|
||||
},
|
||||
DamageLocationsWidget: {
|
||||
Answers: [
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageLocations.windshield,
|
||||
Text: testConstants.cmsConstants.locationCopy.windshield,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageLocations.driver,
|
||||
Text: testConstants.cmsConstants.locationCopy.driver,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: testConstants.cmsConstants.widgetNames.driverDamages
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageLocations.passenger,
|
||||
Text: testConstants.cmsConstants.locationCopy.passenger,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: testConstants.cmsConstants.widgetNames.passengerDamages
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageLocations.rear,
|
||||
Text: testConstants.cmsConstants.locationCopy.rear,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
}
|
||||
]
|
||||
},
|
||||
DriverDamagesWidget: {
|
||||
Answers: [
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.vent,
|
||||
Text: testConstants.cmsConstants.damageCopy.vent,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.front,
|
||||
Text: testConstants.cmsConstants.damageCopy.front,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.back,
|
||||
Text: testConstants.cmsConstants.damageCopy.back,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.quarter,
|
||||
Text: testConstants.cmsConstants.damageCopy.quarter,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.side,
|
||||
Text: testConstants.cmsConstants.damageCopy.side,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
}
|
||||
]
|
||||
},
|
||||
PassengerDamagesWidget: {
|
||||
Answers: [
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.vent,
|
||||
Text: testConstants.cmsConstants.damageCopy.vent,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.front,
|
||||
Text: testConstants.cmsConstants.damageCopy.front,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.back,
|
||||
Text: testConstants.cmsConstants.damageCopy.back,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.quarter,
|
||||
Text: testConstants.cmsConstants.damageCopy.quarter,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
},
|
||||
{
|
||||
Name: testConstants.cmsConstants.damageNames.side,
|
||||
Text: testConstants.cmsConstants.damageCopy.side,
|
||||
SubText: '',
|
||||
ImageId: testConstants.cmsConstants.imageId,
|
||||
Image: '',
|
||||
SubWidgetName: ''
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
getDamageDisplayContent.mockClear();
|
||||
});
|
||||
|
||||
describe('Damage Review Block', () => {
|
||||
describe('Correctly assembles damage info into a display string', () => {
|
||||
test('Shows windshield copy when windshield damage is included', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
cmsWidgetName: testConstants.cmsConstants.widgetNames.header,
|
||||
damageLocationsWidgetName: testConstants.cmsConstants.widgetNames.locations,
|
||||
test('computed displayContent calls getDamageDisplayContent with expected', () => {
|
||||
// Arrange
|
||||
const glassToReplace = ['front-window', 'side-window'];
|
||||
const isRepair = false;
|
||||
const initialStore = {
|
||||
order: {
|
||||
damage: {
|
||||
isRepair: false,
|
||||
glassToReplace: [testConstants.glassItems.windshield]
|
||||
glassToReplace,
|
||||
isRepair
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
const expected = ['a', 'v', 'n'];
|
||||
getDamageDisplayContent.mockImplementationOnce(() => expected);
|
||||
const { wrapper } = getShallowMountedComponent(initialStore, {});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
// Act
|
||||
const result = wrapper.vm.displayContent;
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.windshield
|
||||
]);
|
||||
});
|
||||
|
||||
test('Windshield copy is shown when order is a repair', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
cmsWidgetName: testConstants.cmsConstants.widgetNames.header,
|
||||
damageLocationsWidgetName: testConstants.cmsConstants.widgetNames.locations,
|
||||
damage: {
|
||||
isRepair: true,
|
||||
numberOfChips: 2,
|
||||
glassToReplace: []
|
||||
}
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.windshield
|
||||
]);
|
||||
});
|
||||
|
||||
test('Rear windshield copy shows when rear damage is present', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
cmsWidgetName: testConstants.cmsConstants.widgetNames.header,
|
||||
damageLocationsWidgetName: testConstants.cmsConstants.widgetNames.locations,
|
||||
damage: {
|
||||
isRepair: false,
|
||||
numberOfChips: null,
|
||||
glassToReplace: [testConstants.glassItems.rear]
|
||||
}
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.rear
|
||||
]);
|
||||
});
|
||||
|
||||
test('Driver side copy and items are shown when driver side damage is present', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
cmsWidgetName: testConstants.cmsConstants.widgetNames.header,
|
||||
damageLocationsWidgetName: testConstants.cmsConstants.widgetNames.locations,
|
||||
damage: {
|
||||
isRepair: false,
|
||||
numberOfChips: null,
|
||||
glassToReplace: [
|
||||
testConstants.glassItems.driverItems.back,
|
||||
testConstants.glassItems.driverItems.front
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.driver,
|
||||
testConstants.makeBulletedList([
|
||||
testConstants.cmsConstants.damageCopy.front,
|
||||
testConstants.cmsConstants.damageCopy.back
|
||||
])
|
||||
]);
|
||||
});
|
||||
|
||||
test('Passenger side copy and items are shown when passenger side damage is present', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
cmsWidgetName: testConstants.cmsConstants.widgetNames.header,
|
||||
damageLocationsWidgetName: testConstants.cmsConstants.widgetNames.locations,
|
||||
damage: {
|
||||
isRepair: false,
|
||||
numberOfChips: null,
|
||||
glassToReplace: [
|
||||
testConstants.glassItems.passengerItems.quarter,
|
||||
testConstants.glassItems.passengerItems.vent,
|
||||
testConstants.glassItems.passengerItems.side
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.passenger,
|
||||
testConstants.makeBulletedList([
|
||||
testConstants.cmsConstants.damageCopy.vent,
|
||||
testConstants.cmsConstants.damageCopy.quarter,
|
||||
testConstants.cmsConstants.damageCopy.side
|
||||
])
|
||||
]);
|
||||
});
|
||||
|
||||
test('All relevant sections are shown in order in multiglass scenario', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
cmsWidgetName: testConstants.cmsConstants.widgetNames.header,
|
||||
damageLocationsWidgetName: testConstants.cmsConstants.widgetNames.locations,
|
||||
damage: {
|
||||
isRepair: false,
|
||||
numberOfChips: null,
|
||||
glassToReplace: [
|
||||
testConstants.glassItems.windshield,
|
||||
testConstants.glassItems.rear,
|
||||
testConstants.glassItems.driverItems.vent,
|
||||
testConstants.glassItems.driverItems.front,
|
||||
testConstants.glassItems.driverItems.back,
|
||||
testConstants.glassItems.passengerItems.quarter,
|
||||
testConstants.glassItems.passengerItems.back,
|
||||
testConstants.glassItems.passengerItems.side
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toStrictEqual([
|
||||
testConstants.cmsConstants.locationCopy.windshield,
|
||||
testConstants.cmsConstants.locationCopy.driver,
|
||||
testConstants.makeBulletedList([
|
||||
testConstants.cmsConstants.damageCopy.vent,
|
||||
testConstants.cmsConstants.damageCopy.front,
|
||||
testConstants.cmsConstants.damageCopy.back
|
||||
]),
|
||||
testConstants.cmsConstants.locationCopy.passenger,
|
||||
testConstants.makeBulletedList([
|
||||
testConstants.cmsConstants.damageCopy.back,
|
||||
testConstants.cmsConstants.damageCopy.quarter,
|
||||
testConstants.cmsConstants.damageCopy.side
|
||||
]),
|
||||
testConstants.cmsConstants.locationCopy.rear
|
||||
]);
|
||||
});
|
||||
// Assert
|
||||
expect(result).toStrictEqual(expected);
|
||||
expect(getDamageDisplayContent).toBeCalledTimes(1);
|
||||
expect(getDamageDisplayContent).toBeCalledWith([], [], [], glassToReplace, isRepair);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue