CSR-120: expand test coverage
This commit is contained in:
parent
75f3391423
commit
58a0f3a64a
1 changed files with 104 additions and 18 deletions
|
|
@ -1,11 +1,23 @@
|
||||||
import { shallowMount, enableAutoUnmount } from '@vue/test-utils';
|
import { shallowMount } from '@vue/test-utils';
|
||||||
import vehicleBanner from './vehicle-banner';
|
import vehicleBanner from './vehicle-banner';
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
|
|
||||||
describe('vehicleBanner', () => {
|
describe('vehicleBanner', () => {
|
||||||
// Arrange
|
const $store = {
|
||||||
const mountOptions = getMountOptions({
|
state: {
|
||||||
|
order: {
|
||||||
|
vehicle: {
|
||||||
|
vin: null,
|
||||||
|
year: null,
|
||||||
|
make: null,
|
||||||
|
model: null,
|
||||||
|
style: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const actionList = {
|
||||||
actionList: [
|
actionList: [
|
||||||
{
|
{
|
||||||
actionName: storeActions.LOOKUP_VEHICLE_BY_YMMS,
|
actionName: storeActions.LOOKUP_VEHICLE_BY_YMMS,
|
||||||
|
|
@ -30,33 +42,107 @@ describe('vehicleBanner', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
enableAutoUnmount(afterEach)
|
|
||||||
|
|
||||||
// Act
|
test('renders the blurrycar image when vehicleImageSrc is not present', async () => {
|
||||||
const wrapper = shallowMount(vehicleBanner, {
|
// Arrange
|
||||||
...mountOptions
|
const mountOptions = getMountOptions(actionList);
|
||||||
});
|
mountOptions.global.mocks = {
|
||||||
|
...mountOptions.global.mocks,
|
||||||
// Assert
|
$store
|
||||||
it('renders the blurrycar image when vehicleImageSrc is not present', () => {
|
}
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(vehicleBanner, {
|
||||||
|
...mountOptions
|
||||||
|
});
|
||||||
|
// Assert
|
||||||
expect(wrapper.find('img').attributes('class')).toContain('blurrycar');
|
expect(wrapper.find('img').attributes('class')).toContain('blurrycar');
|
||||||
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Assert
|
test('does not render the blurrycar image when vehicleImageSrc exists', async () => {
|
||||||
it('does not render the blurrycar image when vehicleImageSrc exists', async () => {
|
// Arrange
|
||||||
await wrapper.setData({ 'vehicleImageSrc': 'https://s3.amazonaws.com/safelite-lab-vehicle-images/Evox/8963_cc0320_032_UG_white_2014_Ford_Focus_18029225538399034889.jpg' });
|
const mountOptions = getMountOptions(actionList);
|
||||||
|
mountOptions.global.mocks = {
|
||||||
|
...mountOptions.global.mocks,
|
||||||
|
$store
|
||||||
|
}
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(vehicleBanner, {
|
||||||
|
...mountOptions,
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
vehicleImageSrc: "https://s3.amazonaws.com/safelite-lab-vehicle-images/Evox/8963_cc0320_032_UG_white_2014_Ford_Focus_18029225538399034889.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Assert
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(wrapper.find('img').attributes('class')).not.toContain('blurrycar');
|
expect(wrapper.find('img').attributes('class')).not.toContain('blurrycar');
|
||||||
}, 500);
|
}, 500);
|
||||||
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Assert
|
test('does not render the blurrycar image when passedCarId is set', async () => {
|
||||||
it('does not render the blurrycar image when passedCarId is set', async () => {
|
// Arrange
|
||||||
await wrapper.setProps({ 'passedCarId': 'CR00068434' });
|
const mountOptions = getMountOptions(actionList);
|
||||||
|
mountOptions.global.mocks = {
|
||||||
|
...mountOptions.global.mocks,
|
||||||
|
$store,
|
||||||
|
}
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(vehicleBanner, {
|
||||||
|
...mountOptions,
|
||||||
|
props: {
|
||||||
|
passedCarId: "CR00068434"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Assert
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(wrapper.find('img').attributes('class')).not.toContain('blurrycar');
|
expect(wrapper.find('img').attributes('class')).not.toContain('blurrycar');
|
||||||
}, 500);
|
}, 500);
|
||||||
|
wrapper.unmount();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('does not render the blurrycar image when a YMMS object is found', async () => {
|
||||||
|
// Arrange
|
||||||
|
$store.state.order.vehicle.year = "2019"
|
||||||
|
$store.state.order.vehicle.make = "acura"
|
||||||
|
$store.state.order.vehicle.model = "rdx"
|
||||||
|
$store.state.order.vehicle.style = "4 door utility"
|
||||||
|
const mountOptions = getMountOptions(actionList);
|
||||||
|
mountOptions.global.mocks = {
|
||||||
|
...mountOptions.global.mocks,
|
||||||
|
$store
|
||||||
|
}
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(vehicleBanner, {
|
||||||
|
...mountOptions
|
||||||
|
});
|
||||||
|
// Assert
|
||||||
|
setTimeout(() => {
|
||||||
|
expect(wrapper.find('img').attributes('class')).not.toContain('blurrycar');
|
||||||
|
}, 500);
|
||||||
|
wrapper.unmount();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test('does not render the blurrycar image when a VIN is found', async () => {
|
||||||
|
// Arrange
|
||||||
|
$store.state.order.vehicle.vin = "1J4GW58S4XC541166";
|
||||||
|
const mountOptions = getMountOptions(actionList);
|
||||||
|
mountOptions.global.mocks = {
|
||||||
|
...mountOptions.global.mocks,
|
||||||
|
$store
|
||||||
|
}
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(vehicleBanner, {
|
||||||
|
...mountOptions
|
||||||
|
});
|
||||||
|
// Assert
|
||||||
|
setTimeout(() => {
|
||||||
|
expect(wrapper.find('img').attributes('class')).not.toContain('blurrycar');
|
||||||
|
}, 500);
|
||||||
|
wrapper.unmount();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue