diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-10 21:08:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-10 21:08:26 +0300 |
commit | 8731954e18e2c5969d4a5f67d187892312c463c4 (patch) | |
tree | b8ce4b5012aa5239d3eb3f5168916e0597996742 /spec/frontend/ide/components | |
parent | 69e6424b738ea9ac3c6eed0263fe5a6951df7195 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide/components')
-rw-r--r-- | spec/frontend/ide/components/ide_status_bar_spec.js | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/spec/frontend/ide/components/ide_status_bar_spec.js b/spec/frontend/ide/components/ide_status_bar_spec.js index 0ee16f98e7e..fe392a64013 100644 --- a/spec/frontend/ide/components/ide_status_bar_spec.js +++ b/spec/frontend/ide/components/ide_status_bar_spec.js @@ -1,6 +1,6 @@ -import { mount } from '@vue/test-utils'; import _ from 'lodash'; import { TEST_HOST } from 'helpers/test_constants'; +import { mountExtended } from 'helpers/vue_test_utils_helper'; import IdeStatusBar from '~/ide/components/ide_status_bar.vue'; import IdeStatusMR from '~/ide/components/ide_status_mr.vue'; import { rightSidebarViews } from '~/ide/constants'; @@ -15,6 +15,8 @@ jest.mock('~/lib/utils/poll'); describe('IdeStatusBar component', () => { let wrapper; + const dummyIntervalId = 1337; + let dispatchMock; const findMRStatus = () => wrapper.findComponent(IdeStatusMR); @@ -31,14 +33,21 @@ describe('IdeStatusBar component', () => { ...state, }); - wrapper = mount(IdeStatusBar, { store }); + wrapper = mountExtended(IdeStatusBar, { store }); + dispatchMock = jest.spyOn(store, 'dispatch'); }; + beforeEach(() => { + jest.spyOn(window, 'setInterval').mockReturnValue(dummyIntervalId); + }); + + const findCommitShaLink = () => wrapper.findByTestId('commit-sha-content'); + describe('default', () => { it('triggers a setInterval', () => { mountComponent(); - expect(wrapper.vm.intervalId).not.toBe(null); + expect(window.setInterval).toHaveBeenCalledTimes(1); }); it('renders the statusbar', () => { @@ -47,34 +56,10 @@ describe('IdeStatusBar component', () => { expect(wrapper.classes()).toEqual(['ide-status-bar']); }); - describe('commitAgeUpdate', () => { - beforeEach(() => { - mountComponent(); - jest.spyOn(wrapper.vm, 'commitAgeUpdate').mockImplementation(() => {}); - }); - - afterEach(() => { - jest.clearAllTimers(); - }); - - it('gets called every second', () => { - expect(wrapper.vm.commitAgeUpdate).not.toHaveBeenCalled(); - - jest.advanceTimersByTime(1000); - - expect(wrapper.vm.commitAgeUpdate.mock.calls).toHaveLength(1); - - jest.advanceTimersByTime(1000); - - expect(wrapper.vm.commitAgeUpdate.mock.calls).toHaveLength(2); - }); - }); - describe('getCommitPath', () => { it('returns the path to the commit details', () => { mountComponent(); - - expect(wrapper.vm.getCommitPath('abc123de')).toBe('/commit/abc123de'); + expect(findCommitShaLink().attributes('href')).toBe('/commit/abc123de'); }); }); @@ -95,11 +80,10 @@ describe('IdeStatusBar component', () => { }, }; mountComponent({ pipelines }); - jest.spyOn(wrapper.vm, 'openRightPane').mockImplementation(() => {}); wrapper.find('button').trigger('click'); - expect(wrapper.vm.openRightPane).toHaveBeenCalledWith(rightSidebarViews.pipelines); + expect(dispatchMock).toHaveBeenCalledWith('rightPane/open', rightSidebarViews.pipelines); }); }); |