Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 22:34:23 +0300
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 22:34:23 +0300
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/frontend/boards/components/board_new_issue_spec.js
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/frontend/boards/components/board_new_issue_spec.js')
-rw-r--r--spec/frontend/boards/components/board_new_issue_spec.js115
1 files changed, 115 insertions, 0 deletions
diff --git a/spec/frontend/boards/components/board_new_issue_spec.js b/spec/frontend/boards/components/board_new_issue_spec.js
new file mode 100644
index 00000000000..5a01221a5be
--- /dev/null
+++ b/spec/frontend/boards/components/board_new_issue_spec.js
@@ -0,0 +1,115 @@
+import Vuex from 'vuex';
+import { shallowMount, createLocalVue } from '@vue/test-utils';
+import BoardNewIssue from '~/boards/components/board_new_issue.vue';
+
+import '~/boards/models/list';
+import { mockList, mockGroupProjects } from '../mock_data';
+
+const localVue = createLocalVue();
+
+localVue.use(Vuex);
+
+describe('Issue boards new issue form', () => {
+ let wrapper;
+ let vm;
+
+ const addListNewIssuesSpy = jest.fn();
+
+ const findSubmitButton = () => wrapper.find({ ref: 'submitButton' });
+ const findCancelButton = () => wrapper.find({ ref: 'cancelButton' });
+ const findSubmitForm = () => wrapper.find({ ref: 'submitForm' });
+
+ const submitIssue = () => {
+ const dummySubmitEvent = {
+ preventDefault() {},
+ };
+
+ return findSubmitForm().trigger('submit', dummySubmitEvent);
+ };
+
+ beforeEach(() => {
+ const store = new Vuex.Store({
+ state: { selectedProject: mockGroupProjects[0] },
+ actions: { addListNewIssue: addListNewIssuesSpy },
+ getters: {},
+ });
+
+ wrapper = shallowMount(BoardNewIssue, {
+ propsData: {
+ disabled: false,
+ list: mockList,
+ },
+ store,
+ localVue,
+ provide: {
+ groupId: null,
+ weightFeatureAvailable: false,
+ boardWeight: null,
+ },
+ });
+
+ vm = wrapper.vm;
+
+ return vm.$nextTick();
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('calls submit if submit button is clicked', async () => {
+ jest.spyOn(wrapper.vm, 'submit').mockImplementation();
+ wrapper.setData({ title: 'Testing Title' });
+
+ await vm.$nextTick();
+ await submitIssue();
+ expect(wrapper.vm.submit).toHaveBeenCalled();
+ });
+
+ it('disables submit button if title is empty', () => {
+ expect(findSubmitButton().props().disabled).toBe(true);
+ });
+
+ it('enables submit button if title is not empty', async () => {
+ wrapper.setData({ title: 'Testing Title' });
+
+ await vm.$nextTick();
+ expect(wrapper.find({ ref: 'input' }).element.value).toBe('Testing Title');
+ expect(findSubmitButton().props().disabled).toBe(false);
+ });
+
+ it('clears title after clicking cancel', async () => {
+ findCancelButton().trigger('click');
+
+ await vm.$nextTick();
+ expect(vm.title).toBe('');
+ });
+
+ describe('submit success', () => {
+ it('creates new issue', async () => {
+ wrapper.setData({ title: 'submit issue' });
+
+ await vm.$nextTick();
+ await submitIssue();
+ expect(addListNewIssuesSpy).toHaveBeenCalled();
+ });
+
+ it('enables button after submit', async () => {
+ jest.spyOn(wrapper.vm, 'submit').mockImplementation();
+ wrapper.setData({ title: 'submit issue' });
+
+ await vm.$nextTick();
+ await submitIssue();
+ expect(findSubmitButton().props().disabled).toBe(false);
+ });
+
+ it('clears title after submit', async () => {
+ wrapper.setData({ title: 'submit issue' });
+
+ await vm.$nextTick();
+ await submitIssue();
+ await vm.$nextTick();
+ expect(vm.title).toBe('');
+ });
+ });
+});