-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add aria attributes to loaders
- Add aria-valuenow attribute to linear loader - Add aria-label attribute to both linear and circular loaders - Add unit tests for loaders
- Loading branch information
Showing
7 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
components/loader/src/circular-loader/__tests__/circular-loader.test.js
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,26 @@ | ||
import { mount } from 'enzyme' | ||
import React from 'react' | ||
import { CircularLoader } from '../circular-loader.js' | ||
|
||
describe('Circular Loader', () => { | ||
it('renders the circular loader with aria label', () => { | ||
const wrapper = mount( | ||
<CircularLoader | ||
dataTest={'circular-loader-test'} | ||
ariaLabel="Circular Loader" | ||
/> | ||
) | ||
const actual = wrapper.find({ 'data-test': 'circular-loader-test' }) | ||
expect(actual.prop('role')).toBe('progressbar') | ||
expect(actual.prop('aria-label')).toBe('Circular Loader') | ||
}) | ||
|
||
it('renders the circular loader without aria label', () => { | ||
const wrapper = mount( | ||
<CircularLoader dataTest={'circular-loader-test'} /> | ||
) | ||
const actual = wrapper.find({ 'data-test': 'circular-loader-test' }) | ||
expect(actual.prop('aria-label')).toBe(undefined) | ||
expect(actual.prop('role')).toBe('progressbar') | ||
}) | ||
}) |
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
29 changes: 29 additions & 0 deletions
29
components/loader/src/linear-loader/__tests__/linear-loader.test.js
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,29 @@ | ||
import { mount } from 'enzyme' | ||
import React from 'react' | ||
import { LinearLoader } from '../linear-loader.js' | ||
|
||
describe('Linear Loader', () => { | ||
it('renders the linear loader with provided aria attributes', () => { | ||
const wrapper = mount( | ||
<LinearLoader | ||
dataTest={'linear-loader-test'} | ||
ariaLabel="Linear Loader" | ||
amount={15} | ||
/> | ||
) | ||
const actual = wrapper.find({ 'data-test': 'linear-loader-test' }) | ||
expect(actual.prop('role')).toBe('progressbar') | ||
expect(actual.prop('aria-label')).toBe('Linear Loader') | ||
expect(actual.prop('aria-valuenow')).toBe(15) | ||
}) | ||
|
||
it('renders the linear loader without aria label', () => { | ||
const wrapper = mount( | ||
<LinearLoader dataTest={'linear-loader-test'} amount={45} /> | ||
) | ||
const actual = wrapper.find({ 'data-test': 'linear-loader-test' }) | ||
expect(actual.prop('role')).toBe('progressbar') | ||
expect(actual.prop('aria-label')).toBe(undefined) | ||
expect(actual.prop('aria-valuenow')).toBe(45) | ||
}) | ||
}) |
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
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