diff options
Diffstat (limited to 'spec/frontend/boards/components')
-rw-r--r-- | spec/frontend/boards/components/board_card_move_to_position_spec.js | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/spec/frontend/boards/components/board_card_move_to_position_spec.js b/spec/frontend/boards/components/board_card_move_to_position_spec.js index 01bad53d9e1..7254b9486ef 100644 --- a/spec/frontend/boards/components/board_card_move_to_position_spec.js +++ b/spec/frontend/boards/components/board_card_move_to_position_spec.js @@ -1,8 +1,8 @@ +import { shallowMount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; -import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import BoardCardMoveToPosition from '~/boards/components/board_card_move_to_position.vue'; import { mockList, mockIssue2, mockIssue, mockIssue3, mockIssue4 } from 'jest/boards/mock_data'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; @@ -19,6 +19,7 @@ describe('Board Card Move to position', () => { let trackingSpy; let store; let dispatch; + const itemIndex = 1; const createStoreOptions = () => { const state = { @@ -42,7 +43,7 @@ describe('Board Card Move to position', () => { }; const createComponent = (propsData) => { - wrapper = shallowMountExtended(BoardCardMoveToPosition, { + wrapper = shallowMount(BoardCardMoveToPosition, { store, propsData: { item: mockIssue2, @@ -66,7 +67,6 @@ describe('Board Card Move to position', () => { wrapper.destroy(); }); - const findEllipsesButton = () => wrapper.findByTestId('move-card-dropdown'); const findMoveToPositionDropdown = () => wrapper.findComponent(GlDropdown); const findDropdownItems = () => findMoveToPositionDropdown().findAllComponents(GlDropdownItem); const findDropdownItemAtIndex = (index) => findDropdownItems().at(index); @@ -74,7 +74,7 @@ describe('Board Card Move to position', () => { describe('Dropdown', () => { describe('Dropdown button', () => { it('has an icon with vertical ellipsis', () => { - expect(findEllipsesButton().exists()).toBe(true); + expect(findMoveToPositionDropdown().exists()).toBe(true); expect(findMoveToPositionDropdown().props('icon')).toBe('ellipsis_v'); }); @@ -82,24 +82,11 @@ describe('Board Card Move to position', () => { findMoveToPositionDropdown().vm.$emit('click'); expect(findDropdownItems()).toHaveLength(dropdownOptions.length); }); - - it('is opened on the click of vertical ellipsis and has 1 dropdown items when number of list items > 10', () => { - wrapper.destroy(); - - createComponent({ - list: { - ...mockList, - id: 'gid://gitlab/List/2', - }, - }); - findMoveToPositionDropdown().vm.$emit('click'); - expect(findDropdownItems()).toHaveLength(1); - }); }); describe('Dropdown options', () => { beforeEach(() => { - createComponent({ index: 1 }); + createComponent({ index: itemIndex }); trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); dispatch = jest.spyOn(store, 'dispatch').mockImplementation(() => {}); }); @@ -109,13 +96,13 @@ describe('Board Card Move to position', () => { }); it.each` - dropdownIndex | dropdownLabel | trackLabel | moveAfterId | moveBeforeId - ${0} | ${BoardCardMoveToPosition.i18n.moveToStartText} | ${'move_to_start'} | ${mockIssue.id} | ${undefined} - ${1} | ${BoardCardMoveToPosition.i18n.moveToEndText} | ${'move_to_end'} | ${undefined} | ${mockIssue4.id} + dropdownIndex | dropdownLabel | trackLabel | positionInList + ${0} | ${BoardCardMoveToPosition.i18n.moveToStartText} | ${'move_to_start'} | ${0} + ${1} | ${BoardCardMoveToPosition.i18n.moveToEndText} | ${'move_to_end'} | ${-1} `( 'on click of dropdown index $dropdownIndex with label $dropdownLabel should call moveItem action with tracking label $trackLabel', - async ({ dropdownIndex, dropdownLabel, trackLabel, moveAfterId, moveBeforeId }) => { - await findEllipsesButton().vm.$emit('click'); + async ({ dropdownIndex, dropdownLabel, trackLabel, positionInList }) => { + await findMoveToPositionDropdown().vm.$emit('click'); expect(findDropdownItemAtIndex(dropdownIndex).text()).toBe(dropdownLabel); await findDropdownItemAtIndex(dropdownIndex).vm.$emit('click', { @@ -134,9 +121,10 @@ describe('Board Card Move to position', () => { itemId: mockIssue2.id, itemIid: mockIssue2.iid, itemPath: mockIssue2.referencePath, - moveBeforeId, - moveAfterId, + positionInList, toListId: mockList.id, + allItemsLoadedInList: true, + atIndex: itemIndex, }); }, ); |