Commit f4b18186 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'xanf-vtu-v1-alerts-service' into 'master'

Upgrading VTU to v1: Remove deprecated `methods` usage in alerts_service_form_spec

See merge request gitlab-org/gitlab!50504
parents 5dc5bd3b 028aaed1
import { nextTick } from 'vue';
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
...@@ -22,13 +23,12 @@ describe('AlertsServiceForm', () => { ...@@ -22,13 +23,12 @@ describe('AlertsServiceForm', () => {
let wrapper; let wrapper;
let mockAxios; let mockAxios;
const createComponent = (props = defaultProps, { methods } = {}) => { const createComponent = (props = defaultProps) => {
wrapper = shallowMount(AlertsServiceForm, { wrapper = shallowMount(AlertsServiceForm, {
propsData: { propsData: {
...defaultProps, ...defaultProps,
...props, ...props,
}, },
methods,
}); });
}; };
...@@ -75,25 +75,16 @@ describe('AlertsServiceForm', () => { ...@@ -75,25 +75,16 @@ describe('AlertsServiceForm', () => {
}); });
describe('reset key', () => { describe('reset key', () => {
it('triggers resetKey method', () => { it('updates the authorization key on success', async () => {
const resetKey = jest.fn();
const methods = { resetKey };
createComponent(defaultProps, { methods });
wrapper.find(GlModal).vm.$emit('ok');
expect(resetKey).toHaveBeenCalled();
});
it('updates the authorization key on success', () => {
const formPath = 'some/path'; const formPath = 'some/path';
mockAxios.onPut(formPath, { service: { token: '' } }).replyOnce(200, { token: 'newToken' }); mockAxios.onPut(formPath).replyOnce(200, { token: 'newToken' });
createComponent({ formPath }); createComponent({ formPath });
return wrapper.vm.resetKey().then(() => { wrapper.find(GlModal).vm.$emit('ok');
expect(findAuthorizationKey().attributes('value')).toBe('newToken'); await axios.waitForAll();
});
expect(findAuthorizationKey().attributes('value')).toBe('newToken');
}); });
it('shows flash message on error', () => { it('shows flash message on error', () => {
...@@ -112,16 +103,6 @@ describe('AlertsServiceForm', () => { ...@@ -112,16 +103,6 @@ describe('AlertsServiceForm', () => {
}); });
describe('activate toggle', () => { describe('activate toggle', () => {
it('triggers toggleActivated method', () => {
const toggleActivated = jest.fn();
const methods = { toggleActivated };
createComponent(defaultProps, { methods });
wrapper.find(ToggleButton).vm.$emit('change', true);
expect(toggleActivated).toHaveBeenCalled();
});
describe('successfully completes', () => { describe('successfully completes', () => {
describe.each` describe.each`
initialActivated | value initialActivated | value
...@@ -175,7 +156,7 @@ describe('AlertsServiceForm', () => { ...@@ -175,7 +156,7 @@ describe('AlertsServiceForm', () => {
it('cannot be toggled', () => { it('cannot be toggled', () => {
wrapper.find(ToggleButton).vm.$emit('change'); wrapper.find(ToggleButton).vm.$emit('change');
return wrapper.vm.$nextTick().then(() => { return nextTick().then(() => {
expect(wrapper.find(ToggleButton).props('disabledInput')).toBe(true); expect(wrapper.find(ToggleButton).props('disabledInput')).toBe(true);
}); });
}); });
......
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