This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(menuButton) - accessibility - add aria-controls attribute, when e…
…xists (#2107) * fixing the bug related to the aria-controls pointing to not existing elements * code improve * fix the test, always take proper DOM element, after click element was not updated * changelog updated * Apply suggestions from code review Co-Authored-By: Marija Najdova <mnajdova@gmail.com>
- Loading branch information
Showing
4 changed files
with
33 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/accessibility/test/behaviors/menuButtonBehavior-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { menuButtonBehavior } from '@stardust-ui/accessibility' | ||
|
||
const mockedMenuId = 'anyMenuId' | ||
|
||
describe('MenuButtonBehavior.ts', () => { | ||
test('aria-controls are NOT defined, when menu is NOT open', () => { | ||
const property = { | ||
open: false, | ||
menuId: mockedMenuId, | ||
} | ||
const expectedResult = menuButtonBehavior(property) | ||
expect(expectedResult.attributes.trigger['aria-controls']).toBe(undefined) | ||
}) | ||
test('aria-controls are defined, when menu is open', () => { | ||
const property = { | ||
open: true, | ||
menuId: mockedMenuId, | ||
} | ||
const expectedResult = menuButtonBehavior(property) | ||
expect(expectedResult.attributes.trigger['aria-controls']).toBe(mockedMenuId) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters