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_settings_sidebar_spec.js')
-rw-r--r--spec/frontend/boards/components/board_settings_sidebar_spec.js113
1 files changed, 20 insertions, 93 deletions
diff --git a/spec/frontend/boards/components/board_settings_sidebar_spec.js b/spec/frontend/boards/components/board_settings_sidebar_spec.js
index f6ed483dfc5..71c886351b6 100644
--- a/spec/frontend/boards/components/board_settings_sidebar_spec.js
+++ b/spec/frontend/boards/components/board_settings_sidebar_spec.js
@@ -3,32 +3,23 @@ import { shallowMount } from '@vue/test-utils';
import { MountingPortal } from 'portal-vue';
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 { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import waitForPromises from 'helpers/wait_for_promises';
import { stubComponent } from 'helpers/stub_component';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import BoardSettingsSidebar from '~/boards/components/board_settings_sidebar.vue';
-import { inactiveId, LIST } from '~/boards/constants';
import destroyBoardListMutation from '~/boards/graphql/board_list_destroy.mutation.graphql';
import * as cacheUpdates from '~/boards/graphql/cache_updates';
-import actions from '~/boards/stores/actions';
-import getters from '~/boards/stores/getters';
-import mutations from '~/boards/stores/mutations';
-import sidebarEventHub from '~/sidebar/event_hub';
import { mockLabelList, destroyBoardListMutationResponse } from '../mock_data';
Vue.use(VueApollo);
-Vue.use(Vuex);
describe('BoardSettingsSidebar', () => {
let wrapper;
let mockApollo;
const labelTitle = mockLabelList.label.title;
const labelColor = mockLabelList.label.color;
- const listId = mockLabelList.id;
const modalID = 'board-settings-sidebar-modal';
const destroyBoardListMutationHandlerSuccess = jest
@@ -42,26 +33,12 @@ describe('BoardSettingsSidebar', () => {
const createComponent = ({
canAdminList = false,
list = {},
- sidebarType = LIST,
- activeId = inactiveId,
destroyBoardListMutationHandler = destroyBoardListMutationHandlerSuccess,
- isApolloBoard = false,
} = {}) => {
- const boardLists = {
- [listId]: list,
- };
- const store = new Vuex.Store({
- state: { sidebarType, activeId, boardLists },
- getters,
- mutations,
- actions,
- });
-
mockApollo = createMockApollo([[destroyBoardListMutation, destroyBoardListMutationHandler]]);
wrapper = extendedWrapper(
shallowMount(BoardSettingsSidebar, {
- store,
apolloProvider: mockApollo,
provide: {
canAdminList,
@@ -69,7 +46,6 @@ describe('BoardSettingsSidebar', () => {
isIssueBoard: true,
boardType: 'group',
issuableType: 'issue',
- isApolloBoard,
},
propsData: {
listId: list.id || '',
@@ -100,90 +76,50 @@ describe('BoardSettingsSidebar', () => {
cacheUpdates.setError = jest.fn();
});
- it('finds a MountingPortal component', () => {
- createComponent();
-
- expect(wrapper.findComponent(MountingPortal).props()).toMatchObject({
- mountTo: '#js-right-sidebar-portal',
- append: true,
- name: 'board-settings-sidebar',
- });
- });
-
- describe('when sidebarType is "list"', () => {
- it('finds a GlDrawer component', () => {
+ describe('default', () => {
+ beforeEach(() => {
createComponent();
+ });
+ it('renders a MountingPortal component', () => {
+ expect(wrapper.findComponent(MountingPortal).props()).toMatchObject({
+ mountTo: '#js-right-sidebar-portal',
+ append: true,
+ name: 'board-settings-sidebar',
+ });
+ });
+ it('renders a GlDrawer component', () => {
expect(findDrawer().exists()).toBe(true);
});
describe('on close', () => {
it('closes the sidebar', async () => {
- createComponent();
-
findDrawer().vm.$emit('close');
await nextTick();
expect(wrapper.findComponent(GlDrawer).props('open')).toBe(false);
});
-
- it('closes the sidebar when emitting the correct event', async () => {
- createComponent();
-
- sidebarEventHub.$emit('sidebar.closeAll');
-
- await nextTick();
-
- expect(wrapper.findComponent(GlDrawer).props('open')).toBe(false);
- });
});
- describe('when activeId is zero', () => {
+ describe('when there is no active list', () => {
it('renders GlDrawer with open false', () => {
createComponent();
expect(findDrawer().props('open')).toBe(false);
+ expect(findLabel().exists()).toBe(false);
});
});
- describe('when activeId is greater than zero', () => {
- it('renders GlDrawer with open true', () => {
- createComponent({ list: mockLabelList, activeId: listId });
+ describe('when there is an active list', () => {
+ it('renders GlDrawer with list title and label', () => {
+ createComponent({ list: mockLabelList });
expect(findDrawer().props('open')).toBe(true);
- });
- });
-
- describe('when activeId is in state', () => {
- it('renders label title', () => {
- createComponent({ list: mockLabelList, activeId: listId });
-
expect(findLabel().props('title')).toBe(labelTitle);
- });
-
- it('renders label background color', () => {
- createComponent({ list: mockLabelList, activeId: listId });
-
expect(findLabel().props('backgroundColor')).toBe(labelColor);
});
});
-
- describe('when activeId is not in state', () => {
- it('does not render GlLabel', () => {
- createComponent({ list: mockLabelList });
-
- expect(findLabel().exists()).toBe(false);
- });
- });
- });
-
- describe('when sidebarType is not List', () => {
- it('does not render GlDrawer', () => {
- createComponent({ sidebarType: '' });
-
- expect(findDrawer().props('open')).toBe(false);
- });
});
it('does not render "Remove list" when user cannot admin the boards list', () => {
@@ -193,20 +129,15 @@ describe('BoardSettingsSidebar', () => {
});
describe('when user can admin the boards list', () => {
- it('renders "Remove list" button', () => {
- createComponent({ canAdminList: true, activeId: listId, list: mockLabelList });
+ beforeEach(() => {
+ createComponent({ canAdminList: true, list: mockLabelList });
+ });
+ it('renders "Remove list" button', () => {
expect(findRemoveButton().exists()).toBe(true);
});
it('removes the list', () => {
- createComponent({
- canAdminList: true,
- activeId: listId,
- list: mockLabelList,
- isApolloBoard: true,
- });
-
findRemoveButton().vm.$emit('click');
wrapper.findComponent(GlModal).vm.$emit('primary');
@@ -215,23 +146,19 @@ describe('BoardSettingsSidebar', () => {
});
it('has the correct ID on the button', () => {
- createComponent({ canAdminList: true, activeId: listId, list: mockLabelList });
const binding = getBinding(findRemoveButton().element, 'gl-modal');
expect(binding.value).toBe(modalID);
});
it('has the correct ID on the modal', () => {
- createComponent({ canAdminList: true, activeId: listId, list: mockLabelList });
expect(findModal().props('modalId')).toBe(modalID);
});
it('sets error when destroy list mutation fails', async () => {
createComponent({
canAdminList: true,
- activeId: listId,
list: mockLabelList,
destroyBoardListMutationHandler: destroyBoardListMutationHandlerFailure,
- isApolloBoard: true,
});
findRemoveButton().vm.$emit('click');