diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-03 00:19:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-03 00:19:21 +0300 |
commit | 90693cc231ba6e1645dc57f2a9111a7b5a5ceae0 (patch) | |
tree | 3b2cffdb40c949b2f061b7fd0f52d3214325cc17 /spec/frontend/super_sidebar | |
parent | b9ce0fe1e6311105b7a748126621f9bfbe37fb2e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/super_sidebar')
-rw-r--r-- | spec/frontend/super_sidebar/components/menu_section_spec.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/spec/frontend/super_sidebar/components/menu_section_spec.js b/spec/frontend/super_sidebar/components/menu_section_spec.js index 751c4da5a3d..556e07a2e31 100644 --- a/spec/frontend/super_sidebar/components/menu_section_spec.js +++ b/spec/frontend/super_sidebar/components/menu_section_spec.js @@ -7,6 +7,7 @@ import { stubComponent } from 'helpers/stub_component'; describe('MenuSection component', () => { let wrapper; + const findButton = () => wrapper.find('button'); const findCollapse = () => wrapper.getComponent(GlCollapse); const findNavItems = () => wrapper.findAllComponents(NavItem); const createWrapper = (item, otherProps) => { @@ -22,7 +23,7 @@ describe('MenuSection component', () => { it('renders its title', () => { createWrapper({ title: 'Asdf' }); - expect(wrapper.find('button').text()).toBe('Asdf'); + expect(findButton().text()).toBe('Asdf'); }); it('renders all its subitems', () => { @@ -36,6 +37,12 @@ describe('MenuSection component', () => { expect(findNavItems().length).toBe(2); }); + it('associates button with list with aria-controls', () => { + createWrapper({ title: 'Asdf' }); + expect(findButton().attributes('aria-controls')).toBe('asdf'); + expect(findCollapse().attributes('id')).toBe('asdf'); + }); + describe('collapse behavior', () => { describe('when active', () => { it('is expanded', () => { @@ -47,6 +54,7 @@ describe('MenuSection component', () => { describe('when set to expanded', () => { it('is expanded', () => { createWrapper({ title: 'Asdf' }, { expanded: true }); + expect(findButton().attributes('aria-expanded')).toBe('true'); expect(findCollapse().props('visible')).toBe(true); }); }); @@ -54,6 +62,7 @@ describe('MenuSection component', () => { describe('when not active nor set to expanded', () => { it('is not expanded', () => { createWrapper({ title: 'Asdf' }); + expect(findButton().attributes('aria-expanded')).toBe('false'); expect(findCollapse().props('visible')).toBe(false); }); }); @@ -77,9 +86,9 @@ describe('MenuSection component', () => { describe('`tag` prop', () => { describe('by default', () => { - it('renders as <section> tag', () => { + it('renders as <div> tag', () => { createWrapper({ title: 'Asdf' }); - expect(wrapper.element.tagName).toBe('SECTION'); + expect(wrapper.element.tagName).toBe('DIV'); }); }); |