Merge pull request #842 from Safelite/feature/richardson/SSR-1466

Unit tests for emits
This commit is contained in:
brich1212safe 2024-09-12 15:36:15 -04:00 committed by GitHub
commit 0711143f49
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 3 deletions

View file

@ -86,3 +86,31 @@ describe('Computed', () => {
expect(modalHeader).toBe(mockDataStrings.cmsHeaderText);
});
});
describe('Emits', () => {
test('Should emit cancel-claim-confirmation when method called', async () => {
// Arrange
const { wrapper } = setupMocks();
// Act
wrapper.vm.cancelClaimConfirmation();
await wrapper.vm.$nextTick();
// Assert
expect(wrapper.emitted('cancel-claim-confirmation')).toBeTruthy();
expect(wrapper.emitted('cancel-claim-confirmation').length).toBe(1);
});
test('Should emit return-to-claim when method called', async () => {
// Arrange
const { wrapper } = setupMocks();
// Act
wrapper.vm.returnToClaim();
await wrapper.vm.$nextTick();
// Assert
expect(wrapper.emitted('return-to-claim')).toBeTruthy();
expect(wrapper.emitted('return-to-claim').length).toBe(1);
});
});

View file

@ -1,3 +1,4 @@
/* eslint-disable max-len */
// Components
import coverageStatement from '@/layouts/coverage-statement/coverage-statement.vue';
@ -93,6 +94,8 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
const wrapper = shallowMount(coverageStatement, mountOptions);
wrapper.vm.$refs[CANCEL_CLAIM_REF_NAME].openModal = jest.fn();
wrapper.vm.$refs.siteFooter.disableForwardButton = jest.fn();
wrapper.vm.$refs.siteFooter.enableForwardAction = jest.fn();
return { wrapper };
}

View file

@ -346,9 +346,14 @@ export default {
},
watch: {
selectedProvider() {
if (this.selectedProvider && this.selectedProvider !== SAFELITE_PROVIDER) {
this.$refs[this.CANCEL_CLAIM_REF_NAME].openModal();
this.selectedProvider = '';
if (this.selectedProvider) {
if (this.selectedProvider !== SAFELITE_PROVIDER) {
this.$refs[this.CANCEL_CLAIM_REF_NAME].openModal();
this.selectedProvider = '';
this.$refs.siteFooter.disableForwardButton();
} else {
this.$refs.siteFooter.enableForwardAction();
}
}
},
nextStepsBody(newValue, oldValue) {