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
|
import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import Vuex from 'vuex';
import BoardApp from '~/boards/components/board_app.vue';
describe('BoardApp', () => {
let wrapper;
let store;
Vue.use(Vuex);
const createStore = ({ mockGetters = {} } = {}) => {
store = new Vuex.Store({
state: {},
actions: {
performSearch: jest.fn(),
},
getters: {
isSidebarOpen: () => true,
...mockGetters,
},
});
};
const createComponent = () => {
wrapper = shallowMount(BoardApp, {
store,
provide: {
initialBoardId: 'gid://gitlab/Board/1',
initialFilterParams: {},
},
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
store = null;
});
it("should have 'is-compact' class when sidebar is open", () => {
createStore();
createComponent();
expect(wrapper.classes()).toContain('is-compact');
});
it("should not have 'is-compact' class when sidebar is closed", () => {
createStore({ mockGetters: { isSidebarOpen: () => false } });
createComponent();
expect(wrapper.classes()).not.toContain('is-compact');
});
});
|