提交 c61c3b68 编写于 作者: C Clement Ho

Merge branch 'fe-delete-old-boardservice' into 'master'

change BoardService in favor of boardsStore on board blank state of the component board

See merge request gitlab-org/gitlab-ce!30546
<script> <script>
import { __ } from '~/locale'; import { __ } from '~/locale';
/* global ListLabel */ import ListLabel from '~/boards/models/label';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
...@@ -30,13 +30,17 @@ export default { ...@@ -30,13 +30,17 @@ export default {
}); });
// Save the labels // Save the labels
gl.boardService boardsStore
.generateDefaultLists() .generateDefaultLists()
.then(res => res.data) .then(res => res.data)
.then(data => { .then(data => {
data.forEach(listObj => { data.forEach(listObj => {
const list = boardsStore.findList('title', listObj.title); const list = boardsStore.findList('title', listObj.title);
if (!list) {
return;
}
list.id = listObj.id; list.id = listObj.id;
list.label.id = listObj.label.id; list.label.id = listObj.label.id;
list.getIssues().catch(() => { list.getIssues().catch(() => {
...@@ -69,8 +73,7 @@ export default { ...@@ -69,8 +73,7 @@ export default {
<span <span
:style="{ backgroundColor: label.color }" :style="{ backgroundColor: label.color }"
class="label-color position-relative d-inline-block rounded" class="label-color position-relative d-inline-block rounded"
> ></span>
</span>
{{ label.title }} {{ label.title }}
</li> </li>
</ul> </ul>
......
---
title: Change BoardService in favor of boardsStore on board blank state of the component
board
merge_request: 30546
author: eduarmreyes
type: other
import Vue from 'vue'; import Vue from 'vue';
import boardsStore from '~/boards/stores/boards_store'; import boardsStore from '~/boards/stores/boards_store';
import BoardBlankState from '~/boards/components/board_blank_state.vue'; import BoardBlankState from '~/boards/components/board_blank_state.vue';
import { mockBoardService } from './mock_data';
describe('Boards blank state', () => { describe('Boards blank state', () => {
let vm; let vm;
...@@ -11,9 +10,10 @@ describe('Boards blank state', () => { ...@@ -11,9 +10,10 @@ describe('Boards blank state', () => {
const Comp = Vue.extend(BoardBlankState); const Comp = Vue.extend(BoardBlankState);
boardsStore.create(); 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) => { new Promise((resolve, reject) => {
if (fail) { if (fail) {
...@@ -71,9 +71,14 @@ describe('Boards blank state', () => { ...@@ -71,9 +71,14 @@ describe('Boards blank state', () => {
vm.$el.querySelector('.btn-success').click(); vm.$el.querySelector('.btn-success').click();
setTimeout(() => { setTimeout(() => {
expect(boardsStore.state.lists.length).toBe(2); expect(boardsStore.addList).toHaveBeenCalledTimes(2);
expect(boardsStore.state.lists[0].title).toEqual('To Do'); expect(boardsStore.addList).toHaveBeenCalledWith(
expect(boardsStore.state.lists[1].title).toEqual('Doing'); jasmine.objectContaining({ title: 'To Do' }),
);
expect(boardsStore.addList).toHaveBeenCalledWith(
jasmine.objectContaining({ title: 'Doing' }),
);
done(); done();
}); });
...@@ -86,7 +91,7 @@ describe('Boards blank state', () => { ...@@ -86,7 +91,7 @@ describe('Boards blank state', () => {
setTimeout(() => { setTimeout(() => {
expect(boardsStore.welcomeIsHidden()).toBeFalsy(); expect(boardsStore.welcomeIsHidden()).toBeFalsy();
expect(boardsStore.state.lists.length).toBe(1); expect(boardsStore.removeList).toHaveBeenCalledWith(undefined, 'label');
done(); done();
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册