debian-mirror-gitlab/spec/frontend/boards/components/board_form_spec.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-04-22 19:07:51 +05:30
import { mount } from '@vue/test-utils';
import boardsStore from '~/boards/stores/boards_store';
import boardForm from '~/boards/components/board_form.vue';
import DeprecatedModal from '~/vue_shared/components/deprecated_modal.vue';
2020-07-28 23:09:34 +05:30
import { TEST_HOST } from 'jest/helpers/test_constants';
2020-04-22 19:07:51 +05:30
describe('board_form.vue', () => {
let wrapper;
const propsData = {
canAdminBoard: false,
2020-07-28 23:09:34 +05:30
labelsPath: `${TEST_HOST}/labels/path`,
milestonePath: `${TEST_HOST}/milestone/path`,
2020-04-22 19:07:51 +05:30
};
const findModal = () => wrapper.find(DeprecatedModal);
beforeEach(() => {
boardsStore.state.currentPage = 'edit';
wrapper = mount(boardForm, { propsData });
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
describe('methods', () => {
describe('cancel', () => {
it('resets currentPage', () => {
wrapper.vm.cancel();
expect(boardsStore.state.currentPage).toBe('');
});
});
});
describe('buttons', () => {
it('cancel button triggers cancel()', () => {
wrapper.setMethods({ cancel: jest.fn() });
findModal().vm.$emit('cancel');
return wrapper.vm.$nextTick().then(() => {
expect(wrapper.vm.cancel).toHaveBeenCalled();
});
});
});
});