From 136f6427e9d4033f2897f934f233f2d38897eb26 Mon Sep 17 00:00:00 2001 From: Samantha Ming <sming@gitlab.com> Date: Wed, 19 Jul 2023 21:32:59 +0200 Subject: [PATCH] Fix report_abuse_button_spec.js Fix spec violation in preparation for Vue 3. --- .../users/profile/components/report_abuse_button_spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/frontend/users/profile/components/report_abuse_button_spec.js b/spec/frontend/users/profile/components/report_abuse_button_spec.js index 1ef856c98490..1ca944dce12a 100644 --- a/spec/frontend/users/profile/components/report_abuse_button_spec.js +++ b/spec/frontend/users/profile/components/report_abuse_button_spec.js @@ -1,7 +1,7 @@ import { GlButton } from '@gitlab/ui'; +import { createWrapper } from '@vue/test-utils'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants'; - import ReportAbuseButton from '~/users/profile/components/report_abuse_button.vue'; import AbuseCategorySelector from '~/abuse_reports/components/abuse_category_selector.vue'; @@ -41,7 +41,7 @@ describe('ReportAbuseButton', () => { }); expect(findReportAbuseButton().attributes('aria-label')).toBe( - wrapper.vm.$options.i18n.reportAbuse, + ReportAbuseButton.i18n.reportAbuse, ); }); @@ -69,11 +69,11 @@ describe('ReportAbuseButton', () => { describe('when user hovers out of the button', () => { it(`should emit ${BV_HIDE_TOOLTIP} to close the tooltip`, () => { - jest.spyOn(wrapper.vm.$root, '$emit'); + const rootWrapper = createWrapper(wrapper.vm.$root); findReportAbuseButton().vm.$emit('mouseout'); - expect(wrapper.vm.$root.$emit).toHaveBeenCalledWith(BV_HIDE_TOOLTIP); + expect(rootWrapper.emitted(BV_HIDE_TOOLTIP)).toHaveLength(1); }); }); }); -- GitLab