diff options
Diffstat (limited to 'spec/frontend/projects/commit/components/form_modal_spec.js')
-rw-r--r-- | spec/frontend/projects/commit/components/form_modal_spec.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/frontend/projects/commit/components/form_modal_spec.js b/spec/frontend/projects/commit/components/form_modal_spec.js index 0c8089430d0..93e2ae13628 100644 --- a/spec/frontend/projects/commit/components/form_modal_spec.js +++ b/spec/frontend/projects/commit/components/form_modal_spec.js @@ -3,6 +3,7 @@ import { within } from '@testing-library/dom'; import { shallowMount, mount, createWrapper } from '@vue/test-utils'; import MockAdapter from 'axios-mock-adapter'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; +import api from '~/api'; import axios from '~/lib/utils/axios_utils'; import { BV_SHOW_MODAL } from '~/lib/utils/constants'; import BranchesDropdown from '~/projects/commit/components/branches_dropdown.vue'; @@ -12,6 +13,8 @@ import eventHub from '~/projects/commit/event_hub'; import createStore from '~/projects/commit/store'; import mockData from '../mock_data'; +jest.mock('~/api'); + describe('CommitFormModal', () => { let wrapper; let store; @@ -167,4 +170,16 @@ describe('CommitFormModal', () => { expect(findTargetProject().attributes('value')).toBe('_changed_project_value_'); }); }); + + it('action primary button triggers Redis HLL tracking api call', async () => { + createComponent(mount, {}, {}, { primaryActionEventName: 'test_event' }); + + await wrapper.vm.$nextTick(); + + jest.spyOn(findForm().element, 'submit'); + + getByText(mockData.modalPropsData.i18n.actionPrimaryText).trigger('click'); + + expect(api.trackRedisHllUserEvent).toHaveBeenCalledWith('test_event'); + }); }); |