diff options
author | Eduardo Mejía <eduar.mreyes@gmail.com> | 2019-07-19 04:44:05 +0300 |
---|---|---|
committer | Clement Ho <408677-ClemMakesApps@users.noreply.gitlab.com> | 2019-07-19 04:44:05 +0300 |
commit | 317c787ea8cef306e266d8c46e77bcc029ae45f8 (patch) | |
tree | a3fbf5354d516d381365e6caefd23187d1e05a18 /spec/javascripts/boards | |
parent | 9578b7e9926db5900b5be07f5699aac04e47c0c6 (diff) |
add stub to the boardsStore to spy on it and be able to use toHaveBeenCalledWith for the pre-defined labels test
Diffstat (limited to 'spec/javascripts/boards')
-rw-r--r-- | spec/javascripts/boards/board_blank_state_spec.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/spec/javascripts/boards/board_blank_state_spec.js b/spec/javascripts/boards/board_blank_state_spec.js index 8e2a947b0dd..b64859ec32a 100644 --- a/spec/javascripts/boards/board_blank_state_spec.js +++ b/spec/javascripts/boards/board_blank_state_spec.js @@ -1,7 +1,6 @@ import Vue from 'vue'; import boardsStore from '~/boards/stores/boards_store'; import BoardBlankState from '~/boards/components/board_blank_state.vue'; -import { mockBoardService } from './mock_data'; describe('Boards blank state', () => { let vm; @@ -11,9 +10,10 @@ describe('Boards blank state', () => { const Comp = Vue.extend(BoardBlankState); boardsStore.create(); - gl.boardService = mockBoardService(); - spyOn(gl.boardService, 'generateDefaultLists').and.callFake( + spyOn(boardsStore, 'addList').and.stub(); + spyOn(boardsStore, 'removeList').and.stub(); + spyOn(boardsStore, 'generateDefaultLists').and.callFake( () => new Promise((resolve, reject) => { if (fail) { @@ -71,9 +71,14 @@ describe('Boards blank state', () => { vm.$el.querySelector('.btn-success').click(); setTimeout(() => { - expect(boardsStore.state.lists.length).toBe(2); - expect(boardsStore.state.lists[0].title).toEqual('To Do'); - expect(boardsStore.state.lists[1].title).toEqual('Doing'); + expect(boardsStore.addList).toHaveBeenCalledTimes(2); + expect(boardsStore.addList).toHaveBeenCalledWith( + jasmine.objectContaining({ title: 'To Do' }), + ); + + expect(boardsStore.addList).toHaveBeenCalledWith( + jasmine.objectContaining({ title: 'Doing' }), + ); done(); }); @@ -86,7 +91,7 @@ describe('Boards blank state', () => { setTimeout(() => { expect(boardsStore.welcomeIsHidden()).toBeFalsy(); - expect(boardsStore.state.lists.length).toBe(1); + expect(boardsStore.removeList).toHaveBeenCalledWith(undefined, 'label'); done(); }); |