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 { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
|
||||
describe('vehicleBanner', () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
const $store = {
|
||||
state: {
|
||||
order: {
|
||||
vehicle: {
|
||||
vin: null,
|
||||
year: null,
|
||||
make: null,
|
||||
model: null,
|
||||
style: null
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const actionList = {
|
||||
actionList: [
|
||||
{
|
||||
actionName: storeActions.LOOKUP_VEHICLE_BY_YMMS,
|
||||
|
|
@ -30,33 +42,107 @@ describe('vehicleBanner', () => {
|
|||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
enableAutoUnmount(afterEach)
|
||||
};
|
||||
|
||||
// Act
|
||||
const wrapper = shallowMount(vehicleBanner, {
|
||||
...mountOptions
|
||||
});
|
||||
|
||||
// Assert
|
||||
it('renders the blurrycar image when vehicleImageSrc is not present', () => {
|
||||
test('renders the blurrycar image when vehicleImageSrc is not present', async () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions(actionList);
|
||||
mountOptions.global.mocks = {
|
||||
...mountOptions.global.mocks,
|
||||
$store
|
||||
}
|
||||
// Act
|
||||
const wrapper = shallowMount(vehicleBanner, {
|
||||
...mountOptions
|
||||
});
|
||||
// Assert
|
||||
expect(wrapper.find('img').attributes('class')).toContain('blurrycar');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
// Assert
|
||||
it('does not render the blurrycar image when vehicleImageSrc exists', async () => {
|
||||
await wrapper.setData({ 'vehicleImageSrc': 'https://s3.amazonaws.com/safelite-lab-vehicle-images/Evox/8963_cc0320_032_UG_white_2014_Ford_Focus_18029225538399034889.jpg' });
|
||||
test('does not render the blurrycar image when vehicleImageSrc exists', async () => {
|
||||
// Arrange
|
||||
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(() => {
|
||||
expect(wrapper.find('img').attributes('class')).not.toContain('blurrycar');
|
||||
}, 500);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
// Assert
|
||||
it('does not render the blurrycar image when passedCarId is set', async () => {
|
||||
await wrapper.setProps({ 'passedCarId': 'CR00068434' });
|
||||
test('does not render the blurrycar image when passedCarId is set', async () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions(actionList);
|
||||
mountOptions.global.mocks = {
|
||||
...mountOptions.global.mocks,
|
||||
$store,
|
||||
}
|
||||
// Act
|
||||
const wrapper = shallowMount(vehicleBanner, {
|
||||
...mountOptions,
|
||||
props: {
|
||||
passedCarId: "CR00068434"
|
||||
}
|
||||
});
|
||||
// Assert
|
||||
setTimeout(() => {
|
||||
expect(wrapper.find('img').attributes('class')).not.toContain('blurrycar');
|
||||
}, 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