summaryrefslogtreecommitdiff
path: root/spec/frontend/boards/components/board_content_spec.js
blob: 269067636228321c73388c748d02fb7cbfe806ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import Vuex from 'vuex';
import { createLocalVue, shallowMount } from '@vue/test-utils';
import { GlAlert } from '@gitlab/ui';
import EpicsSwimlanes from 'ee_component/boards/components/epics_swimlanes.vue';
import BoardColumn from 'ee_else_ce/boards/components/board_column.vue';
import getters from 'ee_else_ce/boards/stores/getters';
import { mockListsWithModel } from '../mock_data';
import BoardContent from '~/boards/components/board_content.vue';

const localVue = createLocalVue();
localVue.use(Vuex);

describe('BoardContent', () => {
  let wrapper;

  const defaultState = {
    isShowingEpicsSwimlanes: false,
    boardLists: mockListsWithModel,
    error: undefined,
  };

  const createStore = (state = defaultState) => {
    return new Vuex.Store({
      getters,
      state,
      actions: {
        fetchIssuesForAllLists: () => {},
      },
    });
  };

  const createComponent = state => {
    const store = createStore({
      ...defaultState,
      ...state,
    });
    wrapper = shallowMount(BoardContent, {
      localVue,
      propsData: {
        lists: mockListsWithModel,
        canAdminList: true,
        groupId: 1,
        disabled: false,
        issueLinkBase: '/',
        rootPath: '/',
        boardId: '1',
      },
      store,
    });
  };

  beforeEach(() => {
    createComponent();
  });

  afterEach(() => {
    wrapper.destroy();
  });

  it('renders a BoardColumn component per list', () => {
    expect(wrapper.findAll(BoardColumn)).toHaveLength(mockListsWithModel.length);
  });

  it('does not display EpicsSwimlanes component', () => {
    expect(wrapper.contains(EpicsSwimlanes)).toBe(false);
    expect(wrapper.contains(GlAlert)).toBe(false);
  });
});