diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-25 18:09:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-25 18:09:33 +0300 |
commit | ba8e92f7c9938d7dba333d2396cdd14bfa0de726 (patch) | |
tree | 071d3b0577dce2e95eefa6a504910bc7856181f3 /spec/frontend/super_sidebar | |
parent | d2d913b606702ecefa01f03362602fde256e3f75 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/super_sidebar')
-rw-r--r-- | spec/frontend/super_sidebar/super_sidebar_collapsed_state_manager_spec.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/frontend/super_sidebar/super_sidebar_collapsed_state_manager_spec.js b/spec/frontend/super_sidebar/super_sidebar_collapsed_state_manager_spec.js index cadcf8c08a3..1972e4805d0 100644 --- a/spec/frontend/super_sidebar/super_sidebar_collapsed_state_manager_spec.js +++ b/spec/frontend/super_sidebar/super_sidebar_collapsed_state_manager_spec.js @@ -9,6 +9,7 @@ import { toggleSuperSidebarCollapsed, initSuperSidebarCollapsedState, findPage, + bindSuperSidebarCollapsedEvents, } from '~/super_sidebar/super_sidebar_collapsed_state_manager'; const { xl, sm } = breakpoints; @@ -91,4 +92,38 @@ describe('Super Sidebar Collapsed State Manager', () => { }, ); }); + + describe('bindSuperSidebarCollapsedEvents', () => { + describe('handles width change', () => { + let removeEventListener; + + afterEach(() => { + removeEventListener(); + }); + + it.each` + initialWindowWidth | updatedWindowWidth | hasClassBeforeResize | hasClassAfterResize + ${xl} | ${sm} | ${false} | ${true} + ${sm} | ${xl} | ${true} | ${false} + ${xl} | ${xl} | ${false} | ${false} + ${sm} | ${sm} | ${true} | ${true} + `( + 'when changing width from $initialWindowWidth to $updatedWindowWidth expect the page to be initialized to be done $timesInitalised times', + ({ initialWindowWidth, updatedWindowWidth, hasClassBeforeResize, hasClassAfterResize }) => { + getCookie.mockReturnValue(undefined); + window.innerWidth = initialWindowWidth; + initSuperSidebarCollapsedState(); + + pageHasCollapsedClass(hasClassBeforeResize); + + removeEventListener = bindSuperSidebarCollapsedEvents(); + + window.innerWidth = updatedWindowWidth; + window.dispatchEvent(new Event('resize')); + + pageHasCollapsedClass(hasClassAfterResize); + }, + ); + }); + }); }); |