diff options
author | Mike Greiling <mike@pixelcog.com> | 2018-10-10 20:08:43 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2018-10-10 20:08:43 +0300 |
commit | a01897446075beac31719ff44a9d742d81ce785d (patch) | |
tree | f6d7ac285f95c938283ce4d11097e31c98be30e7 /spec | |
parent | 62bd3045a3c0c3ad979f795ca891a7a641d4e478 (diff) |
Convert remaining issue board components into ES module syntax
Diffstat (limited to 'spec')
-rw-r--r-- | spec/javascripts/boards/board_blank_state_spec.js | 16 | ||||
-rw-r--r-- | spec/javascripts/boards/board_card_spec.js | 22 | ||||
-rw-r--r-- | spec/javascripts/boards/board_list_spec.js | 7 | ||||
-rw-r--r-- | spec/javascripts/boards/board_new_issue_spec.js | 10 | ||||
-rw-r--r-- | spec/javascripts/boards/boards_store_spec.js | 96 | ||||
-rw-r--r-- | spec/javascripts/boards/components/board_spec.js | 4 | ||||
-rw-r--r-- | spec/javascripts/boards/issue_card_spec.js | 1 | ||||
-rw-r--r-- | spec/javascripts/boards/issue_spec.js | 4 | ||||
-rw-r--r-- | spec/javascripts/boards/list_spec.js | 12 | ||||
-rw-r--r-- | spec/javascripts/boards/mock_data.js | 3 |
10 files changed, 87 insertions, 88 deletions
diff --git a/spec/javascripts/boards/board_blank_state_spec.js b/spec/javascripts/boards/board_blank_state_spec.js index 0e4e1697fd0..50505b41313 100644 --- a/spec/javascripts/boards/board_blank_state_spec.js +++ b/spec/javascripts/boards/board_blank_state_spec.js @@ -1,5 +1,5 @@ import Vue from 'vue'; -import '~/boards/stores/boards_store'; +import boardsStore from '~/boards/stores/boards_store'; import BoardBlankState from '~/boards/components/board_blank_state.vue'; import { mockBoardService } from './mock_data'; @@ -10,7 +10,7 @@ describe('Boards blank state', () => { beforeEach((done) => { const Comp = Vue.extend(BoardBlankState); - gl.issueBoards.BoardsStore.create(); + boardsStore.create(); gl.boardService = mockBoardService(); spyOn(gl.boardService, 'generateDefaultLists').and.callFake(() => new Promise((resolve, reject) => { @@ -57,7 +57,7 @@ describe('Boards blank state', () => { vm.$el.querySelector('.btn-default').click(); setTimeout(() => { - expect(gl.issueBoards.BoardsStore.welcomeIsHidden()).toBeTruthy(); + expect(boardsStore.welcomeIsHidden()).toBeTruthy(); done(); }); @@ -67,9 +67,9 @@ describe('Boards blank state', () => { vm.$el.querySelector('.btn-success').click(); setTimeout(() => { - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2); - expect(gl.issueBoards.BoardsStore.state.lists[0].title).toEqual('To Do'); - expect(gl.issueBoards.BoardsStore.state.lists[1].title).toEqual('Doing'); + expect(boardsStore.state.lists.length).toBe(2); + expect(boardsStore.state.lists[0].title).toEqual('To Do'); + expect(boardsStore.state.lists[1].title).toEqual('Doing'); done(); }); @@ -81,8 +81,8 @@ describe('Boards blank state', () => { vm.$el.querySelector('.btn-success').click(); setTimeout(() => { - expect(gl.issueBoards.BoardsStore.welcomeIsHidden()).toBeFalsy(); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1); + expect(boardsStore.welcomeIsHidden()).toBeFalsy(); + expect(boardsStore.state.lists.length).toBe(1); done(); }); diff --git a/spec/javascripts/boards/board_card_spec.js b/spec/javascripts/boards/board_card_spec.js index ad263791cd4..20cfe426807 100644 --- a/spec/javascripts/boards/board_card_spec.js +++ b/spec/javascripts/boards/board_card_spec.js @@ -10,7 +10,7 @@ import eventHub from '~/boards/eventhub'; import '~/vue_shared/models/label'; import '~/vue_shared/models/assignee'; import '~/boards/models/list'; -import '~/boards/stores/boards_store'; +import boardsStore from '~/boards/stores/boards_store'; import boardCard from '~/boards/components/board_card.vue'; import { listObj, boardsMockInterceptor, mockBoardService } from './mock_data'; @@ -23,8 +23,8 @@ describe('Board card', () => { mock.onAny().reply(boardsMockInterceptor); gl.boardService = mockBoardService(); - gl.issueBoards.BoardsStore.create(); - gl.issueBoards.BoardsStore.detail.issue = {}; + boardsStore.create(); + boardsStore.detail.issue = {}; const BoardCardComp = Vue.extend(boardCard); const list = new List(listObj); @@ -62,7 +62,7 @@ describe('Board card', () => { }); it('returns true when detailIssue is equal to card issue', () => { - gl.issueBoards.BoardsStore.detail.issue = vm.issue; + boardsStore.detail.issue = vm.issue; expect(vm.issueDetailVisible).toBe(true); }); @@ -119,19 +119,19 @@ describe('Board card', () => { }); it('does not set detail issue if showDetail is false', () => { - expect(gl.issueBoards.BoardsStore.detail.issue).toEqual({}); + expect(boardsStore.detail.issue).toEqual({}); }); it('does not set detail issue if link is clicked', () => { triggerEvent('mouseup', vm.$el.querySelector('a')); - expect(gl.issueBoards.BoardsStore.detail.issue).toEqual({}); + expect(boardsStore.detail.issue).toEqual({}); }); it('does not set detail issue if button is clicked', () => { triggerEvent('mouseup', vm.$el.querySelector('button')); - expect(gl.issueBoards.BoardsStore.detail.issue).toEqual({}); + expect(boardsStore.detail.issue).toEqual({}); }); it('does not set detail issue if img is clicked', (done) => { @@ -145,7 +145,7 @@ describe('Board card', () => { Vue.nextTick(() => { triggerEvent('mouseup', vm.$el.querySelector('img')); - expect(gl.issueBoards.BoardsStore.detail.issue).toEqual({}); + expect(boardsStore.detail.issue).toEqual({}); done(); }); @@ -154,7 +154,7 @@ describe('Board card', () => { it('does not set detail issue if showDetail is false after mouseup', () => { triggerEvent('mouseup'); - expect(gl.issueBoards.BoardsStore.detail.issue).toEqual({}); + expect(boardsStore.detail.issue).toEqual({}); }); it('sets detail issue to card issue on mouse up', () => { @@ -164,7 +164,7 @@ describe('Board card', () => { triggerEvent('mouseup'); expect(eventHub.$emit).toHaveBeenCalledWith('newDetailIssue', vm.issue); - expect(gl.issueBoards.BoardsStore.detail.list).toEqual(vm.list); + expect(boardsStore.detail.list).toEqual(vm.list); }); it('adds active class if detail issue is set', (done) => { @@ -181,7 +181,7 @@ describe('Board card', () => { it('resets detail issue to empty if already set', () => { spyOn(eventHub, '$emit'); - gl.issueBoards.BoardsStore.detail.issue = vm.issue; + boardsStore.detail.issue = vm.issue; triggerEvent('mousedown'); triggerEvent('mouseup'); diff --git a/spec/javascripts/boards/board_list_spec.js b/spec/javascripts/boards/board_list_spec.js index 290600cf995..037e06cf3b2 100644 --- a/spec/javascripts/boards/board_list_spec.js +++ b/spec/javascripts/boards/board_list_spec.js @@ -1,15 +1,15 @@ /* global List */ /* global ListIssue */ + import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; import Sortable from 'sortablejs'; import BoardList from '~/boards/components/board_list.vue'; import eventHub from '~/boards/eventhub'; -import '~/boards/mixins/sortable_default_options'; import '~/boards/models/issue'; import '~/boards/models/list'; -import '~/boards/stores/boards_store'; +import boardsStore from '~/boards/stores/boards_store'; import { listObj, boardsMockInterceptor, mockBoardService } from './mock_data'; window.Sortable = Sortable; @@ -25,8 +25,7 @@ describe('Board list component', () => { mock = new MockAdapter(axios); mock.onAny().reply(boardsMockInterceptor); gl.boardService = mockBoardService(); - gl.issueBoards.BoardsStore.create(); - gl.IssueBoardsApp = new Vue(); + boardsStore.create(); const BoardListComp = Vue.extend(BoardList); const list = new List(listObj); diff --git a/spec/javascripts/boards/board_new_issue_spec.js b/spec/javascripts/boards/board_new_issue_spec.js index 1245e3e099a..9fea625a4ac 100644 --- a/spec/javascripts/boards/board_new_issue_spec.js +++ b/spec/javascripts/boards/board_new_issue_spec.js @@ -4,6 +4,7 @@ import Vue from 'vue'; import MockAdapter from 'axios-mock-adapter'; import axios from '~/lib/utils/axios_utils'; import boardNewIssue from '~/boards/components/board_new_issue.vue'; +import boardsStore from '~/boards/stores/boards_store'; import '~/boards/models/list'; import { listObj, boardsMockInterceptor, mockBoardService } from './mock_data'; @@ -36,8 +37,7 @@ describe('Issue boards new issue form', () => { mock.onAny().reply(boardsMockInterceptor); gl.boardService = mockBoardService(); - gl.issueBoards.BoardsStore.create(); - gl.IssueBoardsApp = new Vue(); + boardsStore.create(); list = new List(listObj); @@ -148,13 +148,13 @@ describe('Issue boards new issue form', () => { }); it('sets detail issue after submit', (done) => { - expect(gl.issueBoards.BoardsStore.detail.issue.title).toBe(undefined); + expect(boardsStore.detail.issue.title).toBe(undefined); vm.title = 'submit issue'; Vue.nextTick() .then(submitIssue) .then(() => { - expect(gl.issueBoards.BoardsStore.detail.issue.title).toBe('submit issue'); + expect(boardsStore.detail.issue.title).toBe('submit issue'); }) .then(done) .catch(done.fail); @@ -166,7 +166,7 @@ describe('Issue boards new issue form', () => { Vue.nextTick() .then(submitIssue) .then(() => { - expect(gl.issueBoards.BoardsStore.detail.list.id).toBe(list.id); + expect(boardsStore.detail.list.id).toBe(list.id); }) .then(done) .catch(done.fail); diff --git a/spec/javascripts/boards/boards_store_spec.js b/spec/javascripts/boards/boards_store_spec.js index ed43ce9029e..dfd3ea0db66 100644 --- a/spec/javascripts/boards/boards_store_spec.js +++ b/spec/javascripts/boards/boards_store_spec.js @@ -11,7 +11,7 @@ import '~/vue_shared/models/assignee'; import '~/boards/models/issue'; import '~/boards/models/list'; import '~/boards/services/board_service'; -import '~/boards/stores/boards_store'; +import boardsStore from '~/boards/stores/boards_store'; import { listObj, listObjDuplicate, boardsMockInterceptor, mockBoardService } from './mock_data'; describe('Store', () => { @@ -21,7 +21,7 @@ describe('Store', () => { mock = new MockAdapter(axios); mock.onAny().reply(boardsMockInterceptor); gl.boardService = mockBoardService(); - gl.issueBoards.BoardsStore.create(); + boardsStore.create(); spyOn(gl.boardService, 'moveIssue').and.callFake(() => new Promise((resolve) => { resolve(); @@ -38,35 +38,35 @@ describe('Store', () => { }); it('starts with a blank state', () => { - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(0); + expect(boardsStore.state.lists.length).toBe(0); }); describe('lists', () => { it('creates new list without persisting to DB', () => { - gl.issueBoards.BoardsStore.addList(listObj); + boardsStore.addList(listObj); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1); + expect(boardsStore.state.lists.length).toBe(1); }); it('finds list by ID', () => { - gl.issueBoards.BoardsStore.addList(listObj); - const list = gl.issueBoards.BoardsStore.findList('id', listObj.id); + boardsStore.addList(listObj); + const list = boardsStore.findList('id', listObj.id); expect(list.id).toBe(listObj.id); }); it('finds list by type', () => { - gl.issueBoards.BoardsStore.addList(listObj); - const list = gl.issueBoards.BoardsStore.findList('type', 'label'); + boardsStore.addList(listObj); + const list = boardsStore.findList('type', 'label'); expect(list).toBeDefined(); }); it('gets issue when new list added', (done) => { - gl.issueBoards.BoardsStore.addList(listObj); - const list = gl.issueBoards.BoardsStore.findList('id', listObj.id); + boardsStore.addList(listObj); + const list = boardsStore.findList('id', listObj.id); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1); + expect(boardsStore.state.lists.length).toBe(1); setTimeout(() => { expect(list.issues.length).toBe(1); @@ -76,7 +76,7 @@ describe('Store', () => { }); it('persists new list', (done) => { - gl.issueBoards.BoardsStore.new({ + boardsStore.new({ title: 'Test', list_type: 'label', label: { @@ -86,10 +86,10 @@ describe('Store', () => { description: 'testing;' } }); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1); + expect(boardsStore.state.lists.length).toBe(1); setTimeout(() => { - const list = gl.issueBoards.BoardsStore.findList('id', listObj.id); + const list = boardsStore.findList('id', listObj.id); expect(list).toBeDefined(); expect(list.id).toBe(listObj.id); expect(list.position).toBe(0); @@ -98,61 +98,61 @@ describe('Store', () => { }); it('check for blank state adding', () => { - expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(true); + expect(boardsStore.shouldAddBlankState()).toBe(true); }); it('check for blank state not adding', () => { - gl.issueBoards.BoardsStore.addList(listObj); - expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(false); + boardsStore.addList(listObj); + expect(boardsStore.shouldAddBlankState()).toBe(false); }); it('check for blank state adding when closed list exist', () => { - gl.issueBoards.BoardsStore.addList({ + boardsStore.addList({ list_type: 'closed' }); - expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(true); + expect(boardsStore.shouldAddBlankState()).toBe(true); }); it('adds the blank state', () => { - gl.issueBoards.BoardsStore.addBlankState(); + boardsStore.addBlankState(); - const list = gl.issueBoards.BoardsStore.findList('type', 'blank', 'blank'); + const list = boardsStore.findList('type', 'blank', 'blank'); expect(list).toBeDefined(); }); it('removes list from state', () => { - gl.issueBoards.BoardsStore.addList(listObj); + boardsStore.addList(listObj); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1); + expect(boardsStore.state.lists.length).toBe(1); - gl.issueBoards.BoardsStore.removeList(listObj.id, 'label'); + boardsStore.removeList(listObj.id, 'label'); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(0); + expect(boardsStore.state.lists.length).toBe(0); }); it('moves the position of lists', () => { - const listOne = gl.issueBoards.BoardsStore.addList(listObj); - const listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate); + const listOne = boardsStore.addList(listObj); + const listTwo = boardsStore.addList(listObjDuplicate); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2); + expect(boardsStore.state.lists.length).toBe(2); - gl.issueBoards.BoardsStore.moveList(listOne, [listObjDuplicate.id, listObj.id]); + boardsStore.moveList(listOne, [listObjDuplicate.id, listObj.id]); expect(listOne.position).toBe(1); }); it('moves an issue from one list to another', (done) => { - const listOne = gl.issueBoards.BoardsStore.addList(listObj); - const listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate); + const listOne = boardsStore.addList(listObj); + const listTwo = boardsStore.addList(listObjDuplicate); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2); + expect(boardsStore.state.lists.length).toBe(2); setTimeout(() => { expect(listOne.issues.length).toBe(1); expect(listTwo.issues.length).toBe(1); - gl.issueBoards.BoardsStore.moveIssueToList(listOne, listTwo, listOne.findIssue(1)); + boardsStore.moveIssueToList(listOne, listTwo, listOne.findIssue(1)); expect(listOne.issues.length).toBe(0); expect(listTwo.issues.length).toBe(1); @@ -162,19 +162,19 @@ describe('Store', () => { }); it('moves an issue from backlog to a list', (done) => { - const backlog = gl.issueBoards.BoardsStore.addList({ + const backlog = boardsStore.addList({ ...listObj, list_type: 'backlog', }); - const listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate); + const listTwo = boardsStore.addList(listObjDuplicate); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2); + expect(boardsStore.state.lists.length).toBe(2); setTimeout(() => { expect(backlog.issues.length).toBe(1); expect(listTwo.issues.length).toBe(1); - gl.issueBoards.BoardsStore.moveIssueToList(backlog, listTwo, backlog.findIssue(1)); + boardsStore.moveIssueToList(backlog, listTwo, backlog.findIssue(1)); expect(backlog.issues.length).toBe(0); expect(listTwo.issues.length).toBe(1); @@ -184,10 +184,10 @@ describe('Store', () => { }); it('moves issue to top of another list', (done) => { - const listOne = gl.issueBoards.BoardsStore.addList(listObj); - const listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate); + const listOne = boardsStore.addList(listObj); + const listTwo = boardsStore.addList(listObjDuplicate); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2); + expect(boardsStore.state.lists.length).toBe(2); setTimeout(() => { listOne.issues[0].id = 2; @@ -195,7 +195,7 @@ describe('Store', () => { expect(listOne.issues.length).toBe(1); expect(listTwo.issues.length).toBe(1); - gl.issueBoards.BoardsStore.moveIssueToList(listOne, listTwo, listOne.findIssue(2), 0); + boardsStore.moveIssueToList(listOne, listTwo, listOne.findIssue(2), 0); expect(listOne.issues.length).toBe(0); expect(listTwo.issues.length).toBe(2); @@ -207,10 +207,10 @@ describe('Store', () => { }); it('moves issue to bottom of another list', (done) => { - const listOne = gl.issueBoards.BoardsStore.addList(listObj); - const listTwo = gl.issueBoards.BoardsStore.addList(listObjDuplicate); + const listOne = boardsStore.addList(listObj); + const listTwo = boardsStore.addList(listObjDuplicate); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(2); + expect(boardsStore.state.lists.length).toBe(2); setTimeout(() => { listOne.issues[0].id = 2; @@ -218,7 +218,7 @@ describe('Store', () => { expect(listOne.issues.length).toBe(1); expect(listTwo.issues.length).toBe(1); - gl.issueBoards.BoardsStore.moveIssueToList(listOne, listTwo, listOne.findIssue(2), 1); + boardsStore.moveIssueToList(listOne, listTwo, listOne.findIssue(2), 1); expect(listOne.issues.length).toBe(0); expect(listTwo.issues.length).toBe(2); @@ -238,14 +238,14 @@ describe('Store', () => { labels: [], assignees: [], }); - const list = gl.issueBoards.BoardsStore.addList(listObj); + const list = boardsStore.addList(listObj); setTimeout(() => { list.addIssue(issue); expect(list.issues.length).toBe(2); - gl.issueBoards.BoardsStore.moveIssueInList(list, issue, 0, 1, [1, 2]); + boardsStore.moveIssueInList(list, issue, 0, 1, [1, 2]); expect(list.issues[0].id).toBe(2); expect(gl.boardService.moveIssue).toHaveBeenCalledWith(2, null, null, 1, null); diff --git a/spec/javascripts/boards/components/board_spec.js b/spec/javascripts/boards/components/board_spec.js index 19346e305cf..4ebd4cecc08 100644 --- a/spec/javascripts/boards/components/board_spec.js +++ b/spec/javascripts/boards/components/board_spec.js @@ -1,6 +1,6 @@ import Vue from 'vue'; import '~/boards/services/board_service'; -import '~/boards/components/board'; +import Board from '~/boards/components/board'; import '~/boards/models/list'; import { mockBoardService } from '../mock_data'; @@ -21,7 +21,7 @@ describe('Board component', () => { boardId: 1, }); - vm = new gl.issueBoards.Board({ + vm = new Board({ propsData: { boardId: '1', disabled: false, diff --git a/spec/javascripts/boards/issue_card_spec.js b/spec/javascripts/boards/issue_card_spec.js index b6c61e7bad7..58b7d45d913 100644 --- a/spec/javascripts/boards/issue_card_spec.js +++ b/spec/javascripts/boards/issue_card_spec.js @@ -8,7 +8,6 @@ import '~/vue_shared/models/label'; import '~/vue_shared/models/assignee'; import '~/boards/models/issue'; import '~/boards/models/list'; -import '~/boards/stores/boards_store'; import IssueCardInner from '~/boards/components/issue_card_inner.vue'; import { listObj } from './mock_data'; diff --git a/spec/javascripts/boards/issue_spec.js b/spec/javascripts/boards/issue_spec.js index 0beb5782283..e8387068831 100644 --- a/spec/javascripts/boards/issue_spec.js +++ b/spec/javascripts/boards/issue_spec.js @@ -6,7 +6,7 @@ import '~/vue_shared/models/assignee'; import '~/boards/models/issue'; import '~/boards/models/list'; import '~/boards/services/board_service'; -import '~/boards/stores/boards_store'; +import boardsStore from '~/boards/stores/boards_store'; import { mockBoardService } from './mock_data'; describe('Issue model', () => { @@ -14,7 +14,7 @@ describe('Issue model', () => { beforeEach(() => { gl.boardService = mockBoardService(); - gl.issueBoards.BoardsStore.create(); + boardsStore.create(); issue = new ListIssue({ title: 'Testing', diff --git a/spec/javascripts/boards/list_spec.js b/spec/javascripts/boards/list_spec.js index 4232e0fc221..ba6e81a29a9 100644 --- a/spec/javascripts/boards/list_spec.js +++ b/spec/javascripts/boards/list_spec.js @@ -9,7 +9,7 @@ import '~/vue_shared/models/assignee'; import '~/boards/models/issue'; import '~/boards/models/list'; import '~/boards/services/board_service'; -import '~/boards/stores/boards_store'; +import boardsStore from '~/boards/stores/boards_store'; import { listObj, listObjDuplicate, boardsMockInterceptor, mockBoardService } from './mock_data'; describe('List model', () => { @@ -22,7 +22,7 @@ describe('List model', () => { gl.boardService = mockBoardService({ bulkUpdatePath: '/test/issue-boards/board/1/lists', }); - gl.issueBoards.BoardsStore.create(); + boardsStore.create(); list = new List(listObj); }); @@ -58,13 +58,13 @@ describe('List model', () => { }); it('destroys the list', (done) => { - gl.issueBoards.BoardsStore.addList(listObj); - list = gl.issueBoards.BoardsStore.findList('id', listObj.id); - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(1); + boardsStore.addList(listObj); + list = boardsStore.findList('id', listObj.id); + expect(boardsStore.state.lists.length).toBe(1); list.destroy(); setTimeout(() => { - expect(gl.issueBoards.BoardsStore.state.lists.length).toBe(0); + expect(boardsStore.state.lists.length).toBe(0); done(); }, 0); }); diff --git a/spec/javascripts/boards/mock_data.js b/spec/javascripts/boards/mock_data.js index f380ef450db..c28e41ec175 100644 --- a/spec/javascripts/boards/mock_data.js +++ b/spec/javascripts/boards/mock_data.js @@ -1,4 +1,5 @@ -/* global BoardService */ +import BoardService from '~/boards/services/board_service'; + export const listObj = { id: 300, position: 0, |