Commit 758cb0c2 authored by Enrique Alcantara's avatar Enrique Alcantara

Code review feedback

- Use shallowMountExtended
- Simplify tracking tests
parent 8a8a9842
import { BubbleMenu } from '@tiptap/vue-2'; import { BubbleMenu } from '@tiptap/vue-2';
import { shallowMount } from '@vue/test-utils';
import { mockTracking } from 'helpers/tracking_helper'; import { mockTracking } from 'helpers/tracking_helper';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import FormattingBubbleMenu from '~/content_editor/components/formatting_bubble_menu.vue'; import FormattingBubbleMenu from '~/content_editor/components/formatting_bubble_menu.vue';
import { import {
...@@ -22,13 +21,11 @@ describe('content_editor/components/top_toolbar', () => { ...@@ -22,13 +21,11 @@ describe('content_editor/components/top_toolbar', () => {
}; };
const buildWrapper = () => { const buildWrapper = () => {
wrapper = extendedWrapper( wrapper = shallowMountExtended(FormattingBubbleMenu, {
shallowMount(FormattingBubbleMenu, {
provide: { provide: {
tiptapEditor, tiptapEditor,
}, },
}), });
);
}; };
beforeEach(() => { beforeEach(() => {
...@@ -67,12 +64,10 @@ describe('content_editor/components/top_toolbar', () => { ...@@ -67,12 +64,10 @@ describe('content_editor/components/top_toolbar', () => {
}); });
}); });
it.each` it('tracks the execution of toolbar controls', () => {
eventData const eventData = { contentType: 'italic', value: 1 };
${{ contentType: 'bold' }}
${{ contentType: 'italic', value: 1 }}
`('tracks the execution of toolbar controls', ({ eventData }) => {
const { contentType, value } = eventData; const { contentType, value } = eventData;
wrapper.findByTestId(testId).vm.$emit('execute', eventData); wrapper.findByTestId(testId).vm.$emit('execute', eventData);
expect(trackingSpy).toHaveBeenCalledWith(undefined, BUBBLE_MENU_TRACKING_ACTION, { expect(trackingSpy).toHaveBeenCalledWith(undefined, BUBBLE_MENU_TRACKING_ACTION, {
......
import { shallowMount } from '@vue/test-utils';
import { mockTracking } from 'helpers/tracking_helper'; import { mockTracking } from 'helpers/tracking_helper';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import TopToolbar from '~/content_editor/components/top_toolbar.vue'; import TopToolbar from '~/content_editor/components/top_toolbar.vue';
import { import {
TOOLBAR_CONTROL_TRACKING_ACTION, TOOLBAR_CONTROL_TRACKING_ACTION,
...@@ -12,7 +11,7 @@ describe('content_editor/components/top_toolbar', () => { ...@@ -12,7 +11,7 @@ describe('content_editor/components/top_toolbar', () => {
let trackingSpy; let trackingSpy;
const buildWrapper = () => { const buildWrapper = () => {
wrapper = extendedWrapper(shallowMount(TopToolbar)); wrapper = shallowMountExtended(TopToolbar);
}; };
beforeEach(() => { beforeEach(() => {
...@@ -50,12 +49,10 @@ describe('content_editor/components/top_toolbar', () => { ...@@ -50,12 +49,10 @@ describe('content_editor/components/top_toolbar', () => {
}); });
}); });
it.each` it('tracks the execution of toolbar controls', () => {
eventData const eventData = { contentType: 'blockquote', value: 1 };
${{ contentType: 'bold' }}
${{ contentType: 'blockquote', value: 1 }}
`('tracks the execution of toolbar controls', ({ eventData }) => {
const { contentType, value } = eventData; const { contentType, value } = eventData;
wrapper.findByTestId(testId).vm.$emit('execute', eventData); wrapper.findByTestId(testId).vm.$emit('execute', eventData);
expect(trackingSpy).toHaveBeenCalledWith(undefined, TOOLBAR_CONTROL_TRACKING_ACTION, { expect(trackingSpy).toHaveBeenCalledWith(undefined, TOOLBAR_CONTROL_TRACKING_ACTION, {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment