SSR-1167 Unit test cleanup
This commit is contained in:
parent
e6bfe4af7a
commit
80873d77d2
3 changed files with 123 additions and 183 deletions
|
|
@ -3,15 +3,15 @@ import { createTestingPinia } from '@pinia/testing';
|
|||
import cartDropdown from '@/iss-components/cart-dropdown/cart-dropdown.vue';
|
||||
|
||||
// Supporting Files
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import {getEnumName, getMountOptions} from '@/helpers/unit-test-helper.js';
|
||||
import { useMainStore, getDefaultState } from '@/store';
|
||||
import { formatAmountInDollars } from '@/helpers/text-helper.js';
|
||||
import partTypeStrings from '@/constants/part-type-strings';
|
||||
import partNumberStrings from '@/constants/part-number-strings';
|
||||
import { getHighestFullySatisfiedTier, getPackageContents } from '@/helpers/service-package-helper.js';
|
||||
import { getPriceOfLineItems } from '@/helpers/price-calculator.js';
|
||||
import coverageStatuses from "@/constants/coverage-statuses";
|
||||
import coverageType from "@/constants/coverage-type";
|
||||
import coverageStatuses from '@/constants/coverage-statuses';
|
||||
import coverageType from '@/constants/coverage-type';
|
||||
|
||||
const VERIFYING_COVERAGE = 'Verifying coverage';
|
||||
|
||||
|
|
@ -1309,94 +1309,41 @@ describe('cart-dropdown component', () => {
|
|||
});
|
||||
});
|
||||
describe('method', () => {
|
||||
describe('getDisplayed', () => {
|
||||
test('returns "Verifying coverage" when not no comp, not itac, and coverage status PENDING', () => {
|
||||
const dollarAmount = '$84.00';
|
||||
describe.each([
|
||||
[VERIFYING_COVERAGE, coverageStatuses.PENDING, coverageType.NONE],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.PENDING, coverageType.NO_COMP],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.PENDING, coverageType.ITAC],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.PENDING, coverageType.Deductible],
|
||||
[dollarAmount, coverageStatuses.VERIFIED, coverageType.NO_COMP],
|
||||
[dollarAmount, coverageStatuses.VERIFIED, coverageType.ITAC],
|
||||
[dollarAmount, coverageStatuses.VERIFIED, coverageType.Deductible],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.NO_COVERAGE, coverageType.NONE],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.NO_COVERAGE, coverageType.NO_COMP],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.NO_COVERAGE, coverageType.ITAC],
|
||||
[VERIFYING_COVERAGE, coverageStatuses.NO_COVERAGE, coverageType.Deductible]
|
||||
])('getDisplayed', (expected, status, type) => {
|
||||
test(`returns ${expected} when coverage status ${getEnumName(coverageStatuses, status)} and coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.PENDING,
|
||||
coverageType: coverageType.NONE
|
||||
coverageStatus: status,
|
||||
coverageType: type
|
||||
},
|
||||
currentDeductible: 321
|
||||
}
|
||||
};
|
||||
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const amount = 123;
|
||||
formatAmountInDollars.mockReturnValueOnce(dollarAmount);
|
||||
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getDisplayed(amount);
|
||||
const result = wrapper.vm.getDisplayed(0);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(VERIFYING_COVERAGE);
|
||||
});
|
||||
test('returns dollar amount when itac', () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.ITAC
|
||||
},
|
||||
currentDeductible: 321
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const amount = 123;
|
||||
const dollarAmount = '$84.00';
|
||||
formatAmountInDollars.mockImplementationOnce(() => dollarAmount);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getDisplayed(amount);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(dollarAmount);
|
||||
});
|
||||
test('returns dollar amount when no comp', () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.NO_COMP
|
||||
},
|
||||
currentDeductible: 321
|
||||
},
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const amount = 123;
|
||||
const dollarAmount = '$84.00';
|
||||
formatAmountInDollars.mockImplementationOnce(() => dollarAmount);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getDisplayed(amount);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(dollarAmount);
|
||||
});
|
||||
test('returns dollar amount when deductible set, not itac, not no comp, and verified', () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
currentDeductible: 321,
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
const amount = 123;
|
||||
const dollarAmount = '$84.00';
|
||||
formatAmountInDollars
|
||||
.mockImplementationOnce((value) => (value === amount ? dollarAmount : 1));
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.getDisplayed(amount);
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(dollarAmount);
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
describe('getCartItemForVapsPart', () => {
|
||||
|
|
|
|||
|
|
@ -167,112 +167,105 @@ describe('coverageStatement.vue', () => {
|
|||
});
|
||||
});
|
||||
describe('Computed', () => {
|
||||
describe('verified No Comp', () => {
|
||||
describe.each([[false, coverageType.NONE],
|
||||
[false, coverageType.Deductible],
|
||||
[true, coverageType.NO_COMP]])('isNoCompQuoteVisible', (expected, type) => {
|
||||
test(`returns ${expected} coverageStatus is Verified and coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isNoCompQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('verified ITAC', () => {
|
||||
describe.each([[false, coverageType.NONE],
|
||||
[false, coverageType.Deductible],
|
||||
[true, coverageType.ITAC],
|
||||
[false, coverageType.NO_COMP]])('isITACQuoteVisible', (expected, type) => {
|
||||
test(`returns ${expected} when coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isITACQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('verified Deductible', () => {
|
||||
describe.each([[false, coverageType.NONE],
|
||||
[true, coverageType.Deductible],
|
||||
[false, coverageType.ITAC],
|
||||
[false, coverageType.NO_COMP]])('isDeductibleVisible', (expected, type) => {
|
||||
test(`returns ${expected} when coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: type
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isDeductibleVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isDeductibleVisible', () => {
|
||||
const servicePrice = 123;
|
||||
describe('claim registration required', () => {
|
||||
const verifiedDeductibleStoreState = {
|
||||
issConfig: {
|
||||
isClaimRegistrationRequired: true
|
||||
},
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, coverageType.NONE],
|
||||
[false, coverageStatuses.PENDING, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.PENDING, coverageType.ITAC],
|
||||
[false, coverageStatuses.PENDING, coverageType.Deductible],
|
||||
[true, coverageStatuses.VERIFIED, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.ITAC],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NONE],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.ITAC],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NO_COMP]
|
||||
])('isNoCompQuoteVisible', (expected, status, type) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
currentDeductible: servicePrice - 1
|
||||
coverageStatus: status,
|
||||
coverageType: type
|
||||
}
|
||||
}
|
||||
};
|
||||
getPriceOfLineItems.mockReturnValue(servicePrice);
|
||||
test('returns false when register claim not successful', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getMountedComponent(verifiedDeductibleStoreState);
|
||||
useMainStore().order.insuranceCoverage.coverageStatus = coverageStatuses.NO_COVERAGE;
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isDeductibleVisible;
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Assert
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
// Act
|
||||
const result = wrapper.vm.isNoCompQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, coverageType.NONE],
|
||||
[false, coverageStatuses.PENDING, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.PENDING, coverageType.ITAC],
|
||||
[false, coverageStatuses.PENDING, coverageType.Deductible],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.NO_COMP],
|
||||
[true, coverageStatuses.VERIFIED, coverageType.ITAC],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NONE],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.ITAC],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NO_COMP]
|
||||
])('isITACQuoteVisible', (expected, status, type) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status,
|
||||
coverageType: type
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isITACQuoteVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe.each([
|
||||
[false, coverageStatuses.PENDING, coverageType.NONE],
|
||||
[false, coverageStatuses.PENDING, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.PENDING, coverageType.ITAC],
|
||||
[false, coverageStatuses.PENDING, coverageType.Deductible],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.NO_COMP],
|
||||
[false, coverageStatuses.VERIFIED, coverageType.ITAC],
|
||||
[true, coverageStatuses.VERIFIED, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NONE],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.Deductible],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.ITAC],
|
||||
[false, coverageStatuses.NO_COVERAGE, coverageType.NO_COMP]
|
||||
])('isDeductibleVisible', (expected, status, type) => {
|
||||
test(`returns ${expected} when coverageStatus is ${getEnumName(coverageStatuses, status)} coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: status,
|
||||
coverageType: type
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const { wrapper } = getMountedComponent(mainInitialState);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.isDeductibleVisible;
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
describe('isADAS', () => {
|
||||
|
|
@ -679,8 +672,8 @@ describe('coverageStatement.vue', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
describe('ITAC flag', () => {
|
||||
test('ITAC flag updated once component is initialized', async () => {
|
||||
describe('ITAC CoverageType', () => {
|
||||
test('set ITAC coverageType once component is initialized', async () => {
|
||||
// Arrange
|
||||
const mainInitialState = {
|
||||
order: {
|
||||
|
|
@ -705,7 +698,7 @@ describe('coverageStatement.vue', () => {
|
|||
.toHaveBeenCalledWith(coverageType.ITAC);
|
||||
});
|
||||
|
||||
it('Loaded duplicate with previously registered claim => claim registration is not called', async () => {
|
||||
it('Loaded duplicate with previously registered claim => claim registration is not called', async () => {
|
||||
// Arrange
|
||||
const sellingPrice = getRandomInt(50, 100);
|
||||
const deductible = sellingPrice - 1;
|
||||
|
|
|
|||
|
|
@ -1994,7 +1994,7 @@ describe('Store', () => {
|
|||
});
|
||||
|
||||
describe('billToNumberToUse getter', () => {
|
||||
it('returns itacCashBillToNumber when in ITAC flow', () => {
|
||||
it('returns itacCashBillToNumber when coverageType is ITAC', () => {
|
||||
// Arrange
|
||||
store.order.insuranceCoverage.coverageType = coverageType.ITAC;
|
||||
store.issConfig.itacCashBillToNumber = '12345';
|
||||
|
|
@ -2003,7 +2003,7 @@ describe('Store', () => {
|
|||
expect(store.billToNumberToUse).toEqual(store.issConfig.itacCashBillToNumber);
|
||||
});
|
||||
|
||||
it('returns itacFnrBillToNumber when in NoComp flow', () => {
|
||||
it('returns itacFnrBillToNumber when coverageType is No Comp', () => {
|
||||
// Arrange
|
||||
store.order.insuranceCoverage.coverageType = coverageType.NO_COMP;
|
||||
store.issConfig.itacFnrBillToNumber = '12345';
|
||||
|
|
@ -2012,7 +2012,7 @@ describe('Store', () => {
|
|||
expect(store.billToNumberToUse).toEqual(store.issConfig.itacFnrBillToNumber);
|
||||
});
|
||||
|
||||
it('returns billToAccountNumber when not ITAC and not NoComp', () => {
|
||||
it('returns billToAccountNumber when coverageType is Deductible', () => {
|
||||
// Arrange
|
||||
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
|
||||
store.issConfig.billToAccountNumber = '12345';
|
||||
|
|
|
|||
Loading…
Reference in a new issue