Unit tests for license-plate-lookup
This commit is contained in:
parent
b975bfc97c
commit
c55450c81d
4 changed files with 70 additions and 7 deletions
|
|
@ -0,0 +1,63 @@
|
|||
/* eslint-env jest */
|
||||
import { getDamageString } from '@/helpers/damage-helper';
|
||||
import vehicleLookupAlertTypes from '@/constants/vehicle-lookup-alert-types';
|
||||
import { RouterLinkStub } from '@vue/test-utils';
|
||||
import { render } from '@testing-library/vue';
|
||||
import '@testing-library/jest-dom';
|
||||
import LicensePlateLookupAlertsComponent from './license-plate-lookup-alerts/license-plate-lookup-alerts.vue';
|
||||
|
||||
jest.mock('@/helpers/damage-helper');
|
||||
|
||||
const mountOptions = {
|
||||
global: {
|
||||
stubs: {
|
||||
RouterLink: RouterLinkStub,
|
||||
},
|
||||
mixins: [
|
||||
{
|
||||
methods: {
|
||||
getCmsContent: jest.fn(() => ''),
|
||||
getFooterInfoBoxHeight: jest.fn(() => 80),
|
||||
cssClassNameForCmsWidget: jest.fn(() => 'widget-name-mock-class'),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
describe('license-plate-lookup-alerts.vue', () => {
|
||||
test('VehicleNotFoundAlert is displayed on the screen', () => {
|
||||
// Arrange
|
||||
mountOptions.props = {
|
||||
activeAlertType: vehicleLookupAlertTypes.NOT_FOUND,
|
||||
};
|
||||
|
||||
// Act
|
||||
const { queryByRole } = render(LicensePlateLookupAlertsComponent, mountOptions);
|
||||
const VehicleNotFoundAlert = queryByRole('alert', { name: 'vehicle-not-found-alert' });
|
||||
const VehicleNotMatchedAlert = queryByRole('alert', { name: 'vehicle-not-matched-alert'});
|
||||
|
||||
// Assert
|
||||
expect(VehicleNotFoundAlert).toBeVisible();
|
||||
expect(VehicleNotMatchedAlert).toEqual(null);
|
||||
});
|
||||
|
||||
test('VehicleNotMatchedAlert is displayed on the screen', () => {
|
||||
// Arrange
|
||||
getDamageString.mockImplementation(() => 'Mock Damage String');
|
||||
mountOptions.props = {
|
||||
activeAlertType: vehicleLookupAlertTypes.NOT_MATCHED,
|
||||
};
|
||||
|
||||
// Act
|
||||
const { queryByRole } = render(LicensePlateLookupAlertsComponent, mountOptions);
|
||||
const VehicleNotFoundAlert = queryByRole('alert', { name: 'vehicle-not-found-alert' });
|
||||
const VehicleNotMatchedAlert = queryByRole('alert', { name: 'vehicle-not-matched-alert'});
|
||||
|
||||
// Assert
|
||||
expect(VehicleNotMatchedAlert).toBeVisible();
|
||||
expect(VehicleNotFoundAlert).toEqual(null);
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
|
|
@ -85,8 +85,14 @@ describe("navigation", () => {
|
|||
|
||||
// TODO: Create test for navigating forward when user clicks Continue
|
||||
// and information entered is correct (no alerts)
|
||||
// Will be implemented once navigation from page is complete
|
||||
|
||||
// TODO: Create test for license-plate-question component emitting value when user clicks Continue
|
||||
// and information entered is correct (no alerts)
|
||||
|
||||
// TODO: Create test for zip-question component emitting value when user clicks Continue
|
||||
// and information entered is correct (no alerts)
|
||||
|
||||
// *The above will be completed when navigation from page is complete (SSR-179)
|
||||
});
|
||||
|
||||
function setupMocks({
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
// TODO: Create test for component emitting value when user clicks Continue
|
||||
// and information entered is correct (no alerts)
|
||||
// Will be implemented once navigation from page is complete
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
// TODO: Create test for component emitting value when user clicks Continue
|
||||
// and information entered is correct (no alerts)
|
||||
// Will be implemented once navigation from page is complete
|
||||
Loading…
Reference in a new issue