debian-mirror-gitlab/spec/frontend/boards/components/board_form_spec.js
2020-08-09 17:41:57 +05:30

48 lines
1.2 KiB
JavaScript

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';
import { TEST_HOST } from 'jest/helpers/test_constants';
describe('board_form.vue', () => {
let wrapper;
const propsData = {
canAdminBoard: false,
labelsPath: `${TEST_HOST}/labels/path`,
milestonePath: `${TEST_HOST}/milestone/path`,
};
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();
});
});
});
});