unit test WIP
This commit is contained in:
parent
ef6f01a007
commit
342bffae93
2 changed files with 67 additions and 5 deletions
|
|
@ -10,6 +10,8 @@ import { useMainStore } from '@/store/index.js';
|
||||||
import { settleAllPromises } from '@/helpers/layout-helper';
|
import { settleAllPromises } from '@/helpers/layout-helper';
|
||||||
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
||||||
import { render } from '@testing-library/vue';
|
import { render } from '@testing-library/vue';
|
||||||
|
import { getRandomString, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js';
|
||||||
|
|
||||||
|
|
||||||
// Mock fetchCmsContentForPage
|
// Mock fetchCmsContentForPage
|
||||||
// jest.mock('@/helpers/cms-content-helper', () => ({
|
// jest.mock('@/helpers/cms-content-helper', () => ({
|
||||||
|
|
@ -45,18 +47,75 @@ describe('coverageStatement.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(footer.exists()).toBe(true);
|
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
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
//const { wrapper } = setupMocks({});
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
|
||||||
// Act
|
// 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,
|
isVerified: true,
|
||||||
verifiedITAC: true,
|
availableLineItems: [
|
||||||
|
{
|
||||||
|
sellingPrice: sellingPrice,
|
||||||
|
kitPrice: 0,
|
||||||
|
laborAmount: 0,
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
// Assert
|
// 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
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -279,10 +279,13 @@ export default {
|
||||||
},
|
},
|
||||||
verifiedITAC() {
|
verifiedITAC() {
|
||||||
if (this.coverageVerified && !this.verifiedNoComp) {
|
if (this.coverageVerified && !this.verifiedNoComp) {
|
||||||
|
console.log(this.vehicleDeductible);
|
||||||
|
console.log(this.totalServicePrice);
|
||||||
if (this.vehicleDeductible > this.totalServicePrice) {
|
if (this.vehicleDeductible > this.totalServicePrice) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
verifiedDeductible() {
|
verifiedDeductible() {
|
||||||
if (this.coverageVerified && !this.verifiedNoComp) {
|
if (this.coverageVerified && !this.verifiedNoComp) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue