diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-21 00:09:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-21 00:09:48 +0300 |
commit | 7fbb996fde20a9905177e253491f858870cd5882 (patch) | |
tree | 159c692eb50b7eb273fd4013217ceb5fab3296a4 /spec/frontend/super_sidebar | |
parent | 4faa270685797bd689d2035efe7c7e724950eb82 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/super_sidebar')
-rw-r--r-- | spec/frontend/super_sidebar/components/super_sidebar_spec.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/frontend/super_sidebar/components/super_sidebar_spec.js b/spec/frontend/super_sidebar/components/super_sidebar_spec.js index 85f2a63943d..cd2f3c89ed9 100644 --- a/spec/frontend/super_sidebar/components/super_sidebar_spec.js +++ b/spec/frontend/super_sidebar/components/super_sidebar_spec.js @@ -1,5 +1,6 @@ import { nextTick } from 'vue'; import { GlCollapse } from '@gitlab/ui'; +import Mousetrap from 'mousetrap'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import SuperSidebar from '~/super_sidebar/components/super_sidebar.vue'; import HelpCenter from '~/super_sidebar/components/help_center.vue'; @@ -10,9 +11,14 @@ import { SUPER_SIDEBAR_PEEK_OPEN_DELAY, SUPER_SIDEBAR_PEEK_CLOSE_DELAY, } from '~/super_sidebar/constants'; +import { + toggleSuperSidebarCollapsed, + isCollapsed, +} from '~/super_sidebar/super_sidebar_collapsed_state_manager'; import { stubComponent } from 'helpers/stub_component'; import { sidebarData } from '../mock_data'; +jest.mock('~/super_sidebar/super_sidebar_collapsed_state_manager'); const focusInputMock = jest.fn(); describe('SuperSidebar component', () => { @@ -85,6 +91,28 @@ describe('SuperSidebar component', () => { expect(link.attributes('href')).toBe(linkAttrs.href); expect(link.attributes('class')).toContain('gl-display-none'); }); + + it('sets up the sidebar toggle shortcut', () => { + createWrapper(); + + isCollapsed.mockReturnValue(false); + Mousetrap.trigger('mod+\\'); + + expect(toggleSuperSidebarCollapsed).toHaveBeenCalledTimes(1); + expect(toggleSuperSidebarCollapsed).toHaveBeenCalledWith(true, true); + + isCollapsed.mockReturnValue(true); + Mousetrap.trigger('mod+\\'); + + expect(toggleSuperSidebarCollapsed).toHaveBeenCalledTimes(2); + expect(toggleSuperSidebarCollapsed).toHaveBeenCalledWith(false, true); + + jest.spyOn(Mousetrap, 'unbind'); + + wrapper.destroy(); + + expect(Mousetrap.unbind).toHaveBeenCalledWith(['mod+\\']); + }); }); describe('when peeking on hover', () => { |