unit tests for computed properties
This commit is contained in:
parent
fd0d1c1864
commit
14fb8f8d77
1 changed files with 385 additions and 49 deletions
|
|
@ -26,6 +26,31 @@ import { getRandomString, getRandomInt, getRandomBoolean } from '@/helpers/data-
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
describe('coverageStatement.vue', () => {
|
describe('coverageStatement.vue', () => {
|
||||||
|
describe("method arePagePrerequisitesValid...", () => {
|
||||||
|
test("Should return true for valid page requisites if vin exists", () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
useMainStore().order.vehicle.vin = getRandomString(5,20);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(arePagePrerequisitesValid).toBe(true);
|
||||||
|
});
|
||||||
|
test("Should return false for valid page requisites if vin is missing", () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
useMainStore().order.vehicle.vin = null;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(arePagePrerequisitesValid).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
describe('Rendering', () => {
|
describe('Rendering', () => {
|
||||||
test('Should render site header', () => {
|
test('Should render site header', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -47,19 +72,13 @@ describe('coverageStatement.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(footer.exists()).toBe(true);
|
expect(footer.exists()).toBe(true);
|
||||||
});
|
});
|
||||||
test('If coverage verified and not No Comp, and deductible more than service price, verifiedITAC returns true', async () => {
|
});
|
||||||
|
describe('Verified ITAC scenario', () => {
|
||||||
|
test('If coverage verified, not No Comp, and deductible > service price, verifiedITAC returns true', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
//const { wrapper } = setupMocks({});
|
|
||||||
const mountOptions = getMountOptions();
|
const mountOptions = getMountOptions();
|
||||||
|
|
||||||
// Act
|
|
||||||
// await wrapper.setData({
|
|
||||||
// isVerified: true,
|
|
||||||
// })
|
|
||||||
|
|
||||||
const sellingPrice = getRandomInt(100, 500);
|
const sellingPrice = getRandomInt(100, 500);
|
||||||
const deductible = sellingPrice + 1;
|
const deductible = sellingPrice + 1;
|
||||||
|
|
||||||
const mainInitialState = {
|
const mainInitialState = {
|
||||||
order: {
|
order: {
|
||||||
damage: {
|
damage: {
|
||||||
|
|
@ -73,7 +92,6 @@ describe('coverageStatement.vue', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mountOptions.global = {
|
mountOptions.global = {
|
||||||
plugins: [createTestingPinia({
|
plugins: [createTestingPinia({
|
||||||
initialState: {
|
initialState: {
|
||||||
|
|
@ -82,6 +100,7 @@ describe('coverageStatement.vue', () => {
|
||||||
})]
|
})]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
const wrapper = shallowMount(coverageStatement, mountOptions);
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
wrapper.setData({
|
wrapper.setData({
|
||||||
isVerified: true,
|
isVerified: true,
|
||||||
|
|
@ -95,29 +114,372 @@ describe('coverageStatement.vue', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
console.log(sellingPrice);
|
|
||||||
expect(wrapper.vm.verifiedITAC).toBeTruthy();
|
expect(wrapper.vm.verifiedITAC).toBeTruthy();
|
||||||
//expect(wrapper.findComponent({ ref: 'verifiedITACAlert' }).exists()).toBe(true);
|
|
||||||
});
|
});
|
||||||
test('If coverage verified is false, verifiedITAC returns false', () => {
|
test('If coverage unverified, verifiedITAC returns false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.verifiedITAC).toBeFalsy();
|
||||||
});
|
});
|
||||||
test('If No Comp, verifiedITAC returns false', () => {
|
test('If No Comp, verifiedITAC returns false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
});
|
// Act
|
||||||
test('If deductible is less than service price, verified ITAC is false', () => {
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
});
|
isVerified: 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
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.verifiedITAC).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('If deductible < service price, verifiedITAC returns false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
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
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: true,
|
||||||
|
availableLineItems: [
|
||||||
|
{
|
||||||
|
sellingPrice: sellingPrice,
|
||||||
|
kitPrice: 0,
|
||||||
|
laborAmount: 0,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.verifiedITAC).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Verified Deductible scenario', () => {
|
||||||
|
test('If coverage verified, not No Comp, and service price > deductible, verifiedITAC returns true', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
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
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: true,
|
||||||
|
availableLineItems: [
|
||||||
|
{
|
||||||
|
sellingPrice: sellingPrice,
|
||||||
|
kitPrice: 0,
|
||||||
|
laborAmount: 0,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.verifiedDeductible).toBeTruthy();
|
||||||
|
});
|
||||||
|
test('If coverage unverified, verifiedDeductible returns false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('If No Comp, verifiedDeductible returns false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('If service price < deductible, verifiedDeductible returns false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
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
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: true,
|
||||||
|
availableLineItems: [
|
||||||
|
{
|
||||||
|
sellingPrice: sellingPrice,
|
||||||
|
kitPrice: 0,
|
||||||
|
laborAmount: 0,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('No Comp scenario', () => {
|
||||||
|
test('If noCoverage = true, verifiedNoComp returns true', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.verifiedNoComp).toBeTruthy();
|
||||||
|
});
|
||||||
|
test('If noCoverage = false, verifiedNoComp returns false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.verifiedNoComp).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('Unverified scenario', () => {
|
||||||
|
test('If isVerified is false, coverageUnverified returns true, coverageVerified returns false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.coverageUnverified).toBeTruthy();
|
||||||
|
expect(wrapper.vm.coverageVerified).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('If isVerified is true, coverageVerified returns true, coverageUnverified returns false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mountOptions = getMountOptions();
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mountOptions.global = {
|
||||||
|
plugins: [createTestingPinia({
|
||||||
|
initialState: {
|
||||||
|
main: mainInitialState
|
||||||
|
}
|
||||||
|
})]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(coverageStatement, mountOptions);
|
||||||
|
wrapper.setData({
|
||||||
|
isVerified: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.coverageVerified).toBeTruthy();
|
||||||
|
expect(wrapper.vm.coverageUnverified).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const mockMixin = {
|
const mockMixin = {
|
||||||
|
|
@ -196,32 +558,6 @@ function setupMocks()
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
// describe("coverage-statement.vue...", () => {
|
// describe("coverage-statement.vue...", () => {
|
||||||
// describe("method arePagePrerequisitesValid...", () => {
|
|
||||||
// test("Should return true for valid page requisites if vin exists", () => {
|
|
||||||
// // Arrange
|
|
||||||
// const { wrapper } = setupMocks({});
|
|
||||||
// useMainStore().order.vehicle.vin = getRandomString(5,20);
|
|
||||||
|
|
||||||
// // Act
|
|
||||||
// let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
|
||||||
|
|
||||||
// //Assert
|
|
||||||
// expect(arePagePrerequisitesValid).toBe(true);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// test("Should return false for valid page requisites if vin is missing", () => {
|
|
||||||
// // Arrange
|
|
||||||
// const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
// useMainStore().order.vehicle.vin = null;
|
|
||||||
|
|
||||||
// // Act
|
|
||||||
// let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
|
||||||
|
|
||||||
// //Assert
|
|
||||||
// expect(arePagePrerequisitesValid).toBe(false);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// describe("navigation", () => {
|
// describe("navigation", () => {
|
||||||
// test("forwardButtonAction should trigger navigateForward", async () => {
|
// test("forwardButtonAction should trigger navigateForward", async () => {
|
||||||
// // Arrange
|
// // Arrange
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue