unit test WIP

This commit is contained in:
Katie Kroell 2023-07-21 14:06:49 -04:00
parent ef6f01a007
commit 342bffae93
2 changed files with 67 additions and 5 deletions

View file

@ -10,6 +10,8 @@ import { useMainStore } from '@/store/index.js';
import { settleAllPromises } from '@/helpers/layout-helper';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { render } from '@testing-library/vue';
import { getRandomString, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js';
// Mock fetchCmsContentForPage
// jest.mock('@/helpers/cms-content-helper', () => ({
@ -45,18 +47,75 @@ describe('coverageStatement.vue', () => {
// Assert
expect(footer.exists()).toBe(true);
});
test('Should render ITAC alert if ITAC', async () => {
test('If coverage verified and not No Comp, and deductible more than service price, verifiedITAC returns true', async () => {
// Arrange
const { wrapper } = setupMocks({});
//const { wrapper } = setupMocks({});
const mountOptions = getMountOptions();
// Act
await wrapper.setData({
// await wrapper.setData({
// isVerified: true,
// })
const sellingPrice = getRandomInt(100, 500);
const deductible = sellingPrice + 1;
const mainInitialState = {
order: {
damage: {
isRepair: true
},
policy: {
noCoverage: false,
deductible: {
repair: deductible,
}
}
}
};
mountOptions.global = {
plugins: [createTestingPinia({
initialState: {
main: mainInitialState
}
})]
}
const wrapper = shallowMount(coverageStatement, mountOptions);
wrapper.setData({
isVerified: true,
verifiedITAC: true,
availableLineItems: [
{
sellingPrice: sellingPrice,
kitPrice: 0,
laborAmount: 0,
}
]
})
// Assert
expect(wrapper.findComponent({ ref: 'verifiedITACAlert' }).exists()).toBe(true);
console.log(sellingPrice);
expect(wrapper.vm.verifiedITAC).toBeTruthy();
//expect(wrapper.findComponent({ ref: 'verifiedITACAlert' }).exists()).toBe(true);
});
test('If coverage verified is false, verifiedITAC returns false', () => {
});
test('If No Comp, verified ITAC returns false', () => {
});
test('If deductible is less than service price, verified ITAC is false', () => {
});
// need to figure out what happens here
test('If deductible is equal to service price, *TBD', () => {
});
test('If isVerified is true, coverageVerified returns true', () => {
// expect coverageVerified to be true
// expect coverageUnverified to be false
});
})
})

View file

@ -279,10 +279,13 @@ export default {
},
verifiedITAC() {
if (this.coverageVerified && !this.verifiedNoComp) {
console.log(this.vehicleDeductible);
console.log(this.totalServicePrice);
if (this.vehicleDeductible > this.totalServicePrice) {
return true;
}
}
return false;
},
verifiedDeductible() {
if (this.coverageVerified && !this.verifiedNoComp) {