Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/boards/components/board_app_spec.js')
-rw-r--r--spec/frontend/boards/components/board_app_spec.js87
1 files changed, 21 insertions, 66 deletions
diff --git a/spec/frontend/boards/components/board_app_spec.js b/spec/frontend/boards/components/board_app_spec.js
index b16f9b26f40..157c76b4fff 100644
--- a/spec/frontend/boards/components/board_app_spec.js
+++ b/spec/frontend/boards/components/board_app_spec.js
@@ -1,8 +1,6 @@
import { shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
-// eslint-disable-next-line no-restricted-imports
-import Vuex from 'vuex';
import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
@@ -15,34 +13,15 @@ import { rawIssue, boardListsQueryResponse } from '../mock_data';
describe('BoardApp', () => {
let wrapper;
- let store;
let mockApollo;
const errorMessage = 'Failed to fetch lists';
const boardListQueryHandler = jest.fn().mockResolvedValue(boardListsQueryResponse);
const boardListQueryHandlerFailure = jest.fn().mockRejectedValue(new Error(errorMessage));
- Vue.use(Vuex);
Vue.use(VueApollo);
- const createStore = ({ mockGetters = {} } = {}) => {
- store = new Vuex.Store({
- state: {},
- actions: {
- performSearch: jest.fn(),
- },
- getters: {
- isSidebarOpen: () => true,
- ...mockGetters,
- },
- });
- };
-
- const createComponent = ({
- isApolloBoard = false,
- issue = rawIssue,
- handler = boardListQueryHandler,
- } = {}) => {
+ const createComponent = ({ issue = rawIssue, handler = boardListQueryHandler } = {}) => {
mockApollo = createMockApollo([[boardListsQuery, handler]]);
mockApollo.clients.defaultClient.cache.writeQuery({
query: activeBoardItemQuery,
@@ -53,7 +32,6 @@ describe('BoardApp', () => {
wrapper = shallowMount(BoardApp, {
apolloProvider: mockApollo,
- store,
provide: {
fullPath: 'gitlab-org',
initialBoardId: 'gid://gitlab/Board/1',
@@ -62,69 +40,46 @@ describe('BoardApp', () => {
boardType: 'group',
isIssueBoard: true,
isGroupBoard: true,
- isApolloBoard,
},
});
};
- beforeEach(() => {
+ beforeEach(async () => {
cacheUpdates.setError = jest.fn();
- });
- afterEach(() => {
- store = null;
+ createComponent({ isApolloBoard: true });
+ await nextTick();
});
- it("should have 'is-compact' class when sidebar is open", () => {
- createStore();
- createComponent();
+ it('fetches lists', () => {
+ expect(boardListQueryHandler).toHaveBeenCalled();
+ });
+ it('should have is-compact class when a card is selected', () => {
expect(wrapper.classes()).toContain('is-compact');
});
- it("should not have 'is-compact' class when sidebar is closed", () => {
- createStore({ mockGetters: { isSidebarOpen: () => false } });
- createComponent();
+ it('should not have is-compact class when no card is selected', async () => {
+ createComponent({ isApolloBoard: true, issue: {} });
+ await nextTick();
expect(wrapper.classes()).not.toContain('is-compact');
});
- describe('Apollo boards', () => {
- beforeEach(async () => {
- createComponent({ isApolloBoard: true });
- await nextTick();
- });
+ it('refetches lists when updateBoard event is received', async () => {
+ jest.spyOn(eventHub, '$on').mockImplementation(() => {});
- it('fetches lists', () => {
- expect(boardListQueryHandler).toHaveBeenCalled();
- });
+ createComponent({ isApolloBoard: true });
+ await waitForPromises();
- it('should have is-compact class when a card is selected', () => {
- expect(wrapper.classes()).toContain('is-compact');
- });
-
- it('should not have is-compact class when no card is selected', async () => {
- createComponent({ isApolloBoard: true, issue: {} });
- await nextTick();
-
- expect(wrapper.classes()).not.toContain('is-compact');
- });
-
- it('refetches lists when updateBoard event is received', async () => {
- jest.spyOn(eventHub, '$on').mockImplementation(() => {});
-
- createComponent({ isApolloBoard: true });
- await waitForPromises();
-
- expect(eventHub.$on).toHaveBeenCalledWith('updateBoard', wrapper.vm.refetchLists);
- });
+ expect(eventHub.$on).toHaveBeenCalledWith('updateBoard', wrapper.vm.refetchLists);
+ });
- it('sets error on fetch lists failure', async () => {
- createComponent({ isApolloBoard: true, handler: boardListQueryHandlerFailure });
+ it('sets error on fetch lists failure', async () => {
+ createComponent({ isApolloBoard: true, handler: boardListQueryHandlerFailure });
- await waitForPromises();
+ await waitForPromises();
- expect(cacheUpdates.setError).toHaveBeenCalled();
- });
+ expect(cacheUpdates.setError).toHaveBeenCalled();
});
});