diff options
Diffstat (limited to 'spec/frontend/groups/components')
5 files changed, 18 insertions, 24 deletions
diff --git a/spec/frontend/groups/components/app_spec.js b/spec/frontend/groups/components/app_spec.js index 72d8e23f28b..9244e4f331e 100644 --- a/spec/frontend/groups/components/app_spec.js +++ b/spec/frontend/groups/components/app_spec.js @@ -1,5 +1,4 @@ import '~/flash'; -import $ from 'jquery'; import Vue from 'vue'; import AxiosMockAdapter from 'axios-mock-adapter'; import { GlModal, GlLoadingIcon } from '@gitlab/ui'; @@ -123,12 +122,12 @@ describe('AppComponent', () => { it('should show flash error when request fails', () => { mock.onGet('/dashboard/groups.json').reply(400); - jest.spyOn($, 'scrollTo').mockImplementation(() => {}); + jest.spyOn(window, 'scrollTo').mockImplementation(() => {}); jest.spyOn(window, 'Flash').mockImplementation(() => {}); return vm.fetchGroups({}).then(() => { expect(vm.isLoading).toBe(false); - expect($.scrollTo).toHaveBeenCalledWith(0); + expect(window.scrollTo).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 }); expect(window.Flash).toHaveBeenCalledWith('An error occurred. Please try again.'); }); }); @@ -180,7 +179,7 @@ describe('AppComponent', () => { it('should fetch groups for provided page details and update window state', () => { jest.spyOn(urlUtilities, 'mergeUrlParams'); jest.spyOn(window.history, 'replaceState').mockImplementation(() => {}); - jest.spyOn($, 'scrollTo').mockImplementation(() => {}); + jest.spyOn(window, 'scrollTo').mockImplementation(() => {}); const fetchPagePromise = vm.fetchPage(2, null, null, true); @@ -195,7 +194,7 @@ describe('AppComponent', () => { return fetchPagePromise.then(() => { expect(vm.isLoading).toBe(false); - expect($.scrollTo).toHaveBeenCalledWith(0); + expect(window.scrollTo).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 }); expect(urlUtilities.mergeUrlParams).toHaveBeenCalledWith({ page: 2 }, expect.any(String)); expect(window.history.replaceState).toHaveBeenCalledWith( { @@ -308,14 +307,14 @@ describe('AppComponent', () => { const notice = `You left the "${childGroupItem.fullName}" group.`; jest.spyOn(vm.service, 'leaveGroup').mockResolvedValue({ data: { notice } }); jest.spyOn(vm.store, 'removeGroup'); - jest.spyOn($, 'scrollTo').mockImplementation(() => {}); + jest.spyOn(window, 'scrollTo').mockImplementation(() => {}); vm.leaveGroup(); expect(vm.targetGroup.isBeingRemoved).toBe(true); expect(vm.service.leaveGroup).toHaveBeenCalledWith(vm.targetGroup.leavePath); return waitForPromises().then(() => { - expect($.scrollTo).toHaveBeenCalledWith(0); + expect(window.scrollTo).toHaveBeenCalledWith({ behavior: 'smooth', top: 0 }); expect(vm.store.removeGroup).toHaveBeenCalledWith(vm.targetGroup, vm.targetParentGroup); expect($toast.show).toHaveBeenCalledWith(notice); }); diff --git a/spec/frontend/groups/components/group_item_spec.js b/spec/frontend/groups/components/group_item_spec.js index 32bae812c86..d70ea709dee 100644 --- a/spec/frontend/groups/components/group_item_spec.js +++ b/spec/frontend/groups/components/group_item_spec.js @@ -31,7 +31,7 @@ describe('GroupItemComponent', () => { vm.$destroy(); }); - const withMicrodata = group => ({ + const withMicrodata = (group) => ({ ...group, microdata: getGroupItemMicrodata(group), }); @@ -49,7 +49,7 @@ describe('GroupItemComponent', () => { const { rowClass } = vm; expect(Object.keys(rowClass).length).toBe(classes.length); - Object.keys(rowClass).forEach(className => { + Object.keys(rowClass).forEach((className) => { expect(classes.indexOf(className)).toBeGreaterThan(-1); }); }); @@ -220,13 +220,13 @@ describe('GroupItemComponent', () => { }); describe('schema.org props', () => { describe('when showSchemaMarkup is disabled on the group', () => { - it.each(['itemprop', 'itemtype', 'itemscope'], 'it does not set %s', attr => { + it.each(['itemprop', 'itemtype', 'itemscope'], 'it does not set %s', (attr) => { expect(vm.$el.getAttribute(attr)).toBeNull(); }); it.each( ['.js-group-avatar', '.js-group-name', '.js-group-description'], 'it does not set `itemprop` on sub-nodes', - selector => { + (selector) => { expect(vm.$el.querySelector(selector).getAttribute('itemprop')).toBeNull(); }, ); diff --git a/spec/frontend/groups/components/invite_members_banner_spec.js b/spec/frontend/groups/components/invite_members_banner_spec.js index 95003b211fd..4e69f3cd433 100644 --- a/spec/frontend/groups/components/invite_members_banner_spec.js +++ b/spec/frontend/groups/components/invite_members_banner_spec.js @@ -1,5 +1,5 @@ import { shallowMount } from '@vue/test-utils'; -import { GlBanner } from '@gitlab/ui'; +import { GlBanner, GlButton } from '@gitlab/ui'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; import { setCookie, parseBoolean } from '~/lib/utils/common_utils'; import InviteMembersBanner from '~/groups/components/invite_members_banner.vue'; @@ -107,14 +107,12 @@ describe('InviteMembersBanner', () => { }); describe('dismissing', () => { - const findButton = () => { - return wrapper.find('button'); - }; + const findButton = () => wrapper.findAll(GlButton).at(1); beforeEach(() => { wrapper = createComponent({ GlBanner }); - findButton().trigger('click'); + findButton().vm.$emit('click'); }); it('sets iDismissed to true', () => { @@ -138,7 +136,7 @@ describe('InviteMembersBanner', () => { }); it('does not render the banner', () => { - expect(wrapper.contains(GlBanner)).toBe(false); + expect(wrapper.find(GlBanner).exists()).toBe(false); }); }); }); diff --git a/spec/frontend/groups/components/item_stats_spec.js b/spec/frontend/groups/components/item_stats_spec.js index d8c88a608ac..f350012ebed 100644 --- a/spec/frontend/groups/components/item_stats_spec.js +++ b/spec/frontend/groups/components/item_stats_spec.js @@ -44,7 +44,7 @@ describe('ItemStats', () => { expect(findItemStatsValue().exists()).toBe(true); expect(findItemStatsValue().props('cssClass')).toBe('project-stars'); - expect(wrapper.contains('.last-updated')).toBe(true); + expect(wrapper.find('.last-updated').exists()).toBe(true); }); }); }); diff --git a/spec/frontend/groups/components/visibility_level_dropdown_spec.js b/spec/frontend/groups/components/visibility_level_dropdown_spec.js index bf9508dc768..61b7bbb0833 100644 --- a/spec/frontend/groups/components/visibility_level_dropdown_spec.js +++ b/spec/frontend/groups/components/visibility_level_dropdown_spec.js @@ -11,7 +11,7 @@ describe('Visibility Level Dropdown', () => { ]; const defaultLevel = 0; - const createComponent = propsData => { + const createComponent = (propsData) => { wrapper = shallowMount(Component, { propsData, }); @@ -33,7 +33,7 @@ describe('Visibility Level Dropdown', () => { wrapper.find("input[name='group[visibility_level]']").attributes('value'); const dropdownText = () => wrapper.find(GlDropdown).props('text'); const findDropdownItems = () => - wrapper.findAll(GlDropdownItem).wrappers.map(option => ({ + wrapper.findAll(GlDropdownItem).wrappers.map((option) => ({ text: option.text(), secondaryText: option.props('secondaryText'), })); @@ -56,10 +56,7 @@ describe('Visibility Level Dropdown', () => { describe('Selecting an option', () => { beforeEach(() => { - wrapper - .findAll(GlDropdownItem) - .at(1) - .vm.$emit('click'); + wrapper.findAll(GlDropdownItem).at(1).vm.$emit('click'); }); it('sets the value of the hidden input to the selected value', () => { |