Commit 16d431fc authored by Himanshu Kapoor's avatar Himanshu Kapoor

Migrate ee/boards specs to Jest

Migrate specs in ee/spec/javascripts/boards to Jest
parent b146cfda
<script> <script>
import '~/gl_dropdown';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import UsersSelect from '~/users_select'; import UsersSelect from '~/users_select';
......
...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter';
import Vue from 'vue'; import Vue from 'vue';
import AssigneeSelect from 'ee/boards/components/assignee_select.vue'; import AssigneeSelect from 'ee/boards/components/assignee_select.vue';
import { boardObj } from 'spec/boards/mock_data'; import { boardObj } from 'jest/boards/mock_data';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import boardsStore from '~/boards/stores/boards_store'; import boardsStore from '~/boards/stores/boards_store';
...@@ -51,7 +51,7 @@ describe('Assignee select component', () => { ...@@ -51,7 +51,7 @@ describe('Assignee select component', () => {
}, },
}).$mount('.test-container'); }).$mount('.test-container');
setTimeout(done); setImmediate(done);
}); });
describe('canEdit', () => { describe('canEdit', () => {
...@@ -100,10 +100,12 @@ describe('Assignee select component', () => { ...@@ -100,10 +100,12 @@ describe('Assignee select component', () => {
it('sets assignee', done => { it('sets assignee', done => {
vm.$el.querySelector('.edit-link').click(); vm.$el.querySelector('.edit-link').click();
setTimeout(() => { jest.runOnlyPendingTimers();
setImmediate(() => {
vm.$el.querySelectorAll('li a')[2].click(); vm.$el.querySelectorAll('li a')[2].click();
setTimeout(() => { setImmediate(() => {
expect(activeDropdownItem(0)).toEqual('second assignee'); expect(activeDropdownItem(0)).toEqual('second assignee');
expect(vm.board.assignee).toEqual(assignee2); expect(vm.board.assignee).toEqual(assignee2);
done(); done();
......
...@@ -9,6 +9,7 @@ describe('BoardList Component', () => { ...@@ -9,6 +9,7 @@ describe('BoardList Component', () => {
project: { project: {
path: '/test', path: '/test',
}, },
real_path: '',
}; };
const componentProps = { const componentProps = {
......
import Vue from 'vue'; import Vue from 'vue';
import MockAdapater from 'axios-mock-adapter'; import MockAdapater from 'axios-mock-adapter';
import MilestoneSelect from 'ee/boards/components/milestone_select.vue'; import MilestoneSelect from 'ee/boards/components/milestone_select.vue';
import { boardObj } from 'spec/boards/mock_data'; import { boardObj } from 'jest/boards/mock_data';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import IssuableContext from '~/issuable_context'; import IssuableContext from '~/issuable_context';
...@@ -45,7 +45,7 @@ describe('Milestone select component', () => { ...@@ -45,7 +45,7 @@ describe('Milestone select component', () => {
}, },
}).$mount('.test-container'); }).$mount('.test-container');
setTimeout(done); setImmediate(done);
}); });
describe('canEdit', () => { describe('canEdit', () => {
...@@ -103,15 +103,18 @@ describe('Milestone select component', () => { ...@@ -103,15 +103,18 @@ describe('Milestone select component', () => {
mock.restore(); mock.restore();
}); });
it('sets Any milestone', done => { it('sets Any milestone', async done => {
vm.board.milestone_id = 0; vm.board.milestone_id = 0;
vm.$el.querySelector('.edit-link').click(); vm.$el.querySelector('.edit-link').click();
setTimeout(() => { await vm.$nextTick();
jest.runOnlyPendingTimers();
setImmediate(() => {
vm.$el.querySelectorAll('li a')[0].click(); vm.$el.querySelectorAll('li a')[0].click();
}); });
setTimeout(() => { setImmediate(() => {
expect(activeDropdownItem(0)).toEqual('Any milestone'); expect(activeDropdownItem(0)).toEqual('Any milestone');
expect(selectedText()).toEqual('Any milestone'); expect(selectedText()).toEqual('Any milestone');
done(); done();
...@@ -121,11 +124,13 @@ describe('Milestone select component', () => { ...@@ -121,11 +124,13 @@ describe('Milestone select component', () => {
it('sets No milestone', done => { it('sets No milestone', done => {
vm.$el.querySelector('.edit-link').click(); vm.$el.querySelector('.edit-link').click();
setTimeout(() => { jest.runOnlyPendingTimers();
setImmediate(() => {
vm.$el.querySelectorAll('li a')[1].click(); vm.$el.querySelectorAll('li a')[1].click();
}); });
setTimeout(() => { setImmediate(() => {
expect(activeDropdownItem(0)).toEqual('No milestone'); expect(activeDropdownItem(0)).toEqual('No milestone');
expect(selectedText()).toEqual('No milestone'); expect(selectedText()).toEqual('No milestone');
done(); done();
...@@ -135,11 +140,13 @@ describe('Milestone select component', () => { ...@@ -135,11 +140,13 @@ describe('Milestone select component', () => {
it('sets milestone', done => { it('sets milestone', done => {
vm.$el.querySelector('.edit-link').click(); vm.$el.querySelector('.edit-link').click();
setTimeout(() => { jest.runOnlyPendingTimers();
setImmediate(() => {
vm.$el.querySelectorAll('li a')[4].click(); vm.$el.querySelectorAll('li a')[4].click();
}); });
setTimeout(() => { setImmediate(() => {
expect(activeDropdownItem(0)).toEqual('first milestone'); expect(activeDropdownItem(0)).toEqual('first milestone');
expect(selectedText()).toEqual('first milestone'); expect(selectedText()).toEqual('first milestone');
expect(vm.board.milestone).toEqual(milestone); expect(vm.board.milestone).toEqual(milestone);
......
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