2021-11-11 11:23:49 +05:30
|
|
|
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,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
const createComponent = () => {
|
2021-11-11 11:23:49 +05:30
|
|
|
wrapper = shallowMount(BoardApp, {
|
|
|
|
store,
|
|
|
|
provide: {
|
2023-04-23 21:23:45 +05:30
|
|
|
initialBoardId: 'gid://gitlab/Board/1',
|
2021-11-11 11:23:49 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
});
|