diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 15:09:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 15:09:08 +0300 |
commit | 7cc6872401eb487ed20dbb9d455f8bb9c97d9e39 (patch) | |
tree | 63f6ed5d4e6c5cec31c43363626d9f5b178eddf8 /spec/frontend/registry | |
parent | 46b10c0fc884400941c17e2777b242ac54d111e5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/registry')
-rw-r--r-- | spec/frontend/registry/settings/components/settings_form_spec.js | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/spec/frontend/registry/settings/components/settings_form_spec.js b/spec/frontend/registry/settings/components/settings_form_spec.js index 996804f6d08..5b81d034e14 100644 --- a/spec/frontend/registry/settings/components/settings_form_spec.js +++ b/spec/frontend/registry/settings/components/settings_form_spec.js @@ -1,4 +1,5 @@ import { mount } from '@vue/test-utils'; +import Tracking from '~/tracking'; import stubChildren from 'helpers/stub_children'; import component from '~/registry/settings/components/settings_form.vue'; import { createStore } from '~/registry/settings/store/'; @@ -15,6 +16,9 @@ describe('Settings Form', () => { let dispatchSpy; const FORM_ELEMENTS_ID_PREFIX = '#expiration-policy'; + const trackingPayload = { + label: 'docker_container_retention_and_expiration_policies', + }; const GlLoadingIcon = { name: 'gl-loading-icon-stub', template: '<svg></svg>' }; @@ -48,6 +52,7 @@ describe('Settings Form', () => { store.dispatch('setInitialState', stringifiedFormOptions); dispatchSpy = jest.spyOn(store, 'dispatch'); mountComponent(); + jest.spyOn(Tracking, 'event'); }); afterEach(() => { @@ -118,15 +123,23 @@ describe('Settings Form', () => { beforeEach(() => { form = findForm(); }); - it('cancel has type reset', () => { - expect(findCancelButton().attributes('type')).toBe('reset'); - }); - it('form reset event call the appropriate function', () => { - dispatchSpy.mockReturnValue(); - form.trigger('reset'); - // expect.any(Object) is necessary because the event payload is passed to the function - expect(dispatchSpy).toHaveBeenCalledWith('resetSettings', expect.any(Object)); + describe('form cancel event', () => { + it('has type reset', () => { + expect(findCancelButton().attributes('type')).toBe('reset'); + }); + + it('calls the appropriate function', () => { + dispatchSpy.mockReturnValue(); + form.trigger('reset'); + expect(dispatchSpy).toHaveBeenCalledWith('resetSettings'); + }); + + it('tracks the reset event', () => { + dispatchSpy.mockReturnValue(); + form.trigger('reset'); + expect(Tracking.event).toHaveBeenCalledWith(undefined, 'reset_form', trackingPayload); + }); }); it('save has type submit', () => { @@ -177,6 +190,12 @@ describe('Settings Form', () => { expect(dispatchSpy).toHaveBeenCalledWith('saveSettings'); }); + it('tracks the submit event', () => { + dispatchSpy.mockResolvedValue(); + form.trigger('submit'); + expect(Tracking.event).toHaveBeenCalledWith(undefined, 'submit_form', trackingPayload); + }); + it('show a success toast when submit succeed', () => { dispatchSpy.mockResolvedValue(); form.trigger('submit'); |