-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add accessibility properties for ariaLabel, ariaDescribedBy and…
… ariaLabelledBy
- Loading branch information
1 parent
d0c62fb
commit 61addc5
Showing
5 changed files
with
754 additions
and
95 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
/* @flow */ | ||
const {describe, it} = global; | ||
import React from 'react'; | ||
import ShallowRenderer from 'react-test-renderer/shallow'; | ||
// import ShallowRenderer from 'react-test-renderer/shallow'; | ||
import expect from 'expect'; | ||
import {render, screen} from '@testing-library/react'; | ||
import RichTextEditor, {createEmptyValue} from '../RichTextEditor'; | ||
|
||
describe('RichTextEditor', () => { | ||
it('should render', () => { | ||
let renderer = new ShallowRenderer(); | ||
let value = createEmptyValue(); | ||
renderer.render(<RichTextEditor value={value} />); | ||
let output = renderer.getRenderOutput(); | ||
expect(output.type).toEqual('div'); | ||
expect(output.props.className).toBeA('string'); | ||
expect(output.props.className).toInclude('RichTextEditor__root'); | ||
const {container} = render(<RichTextEditor value={value} ariaLabel="Hello Westeros" />); | ||
expect(container.querySelector('div').className).toInclude('RichTextEditor__root___'); | ||
}); | ||
|
||
describe('accessibility', () => { | ||
it('should have the given ariaLabel', () => { | ||
let value = createEmptyValue(); | ||
render(<RichTextEditor value={value} ariaLabel="Hello Westeros" />); | ||
expect(screen.getByRole('textbox').getAttribute('aria-label')).toEqual('Hello Westeros'); | ||
}); | ||
|
||
it('should have the given ariaLabelledBy', () => { | ||
let value = createEmptyValue(); | ||
render(<RichTextEditor value={value} ariaLabelledBy="jonsnow" />); | ||
expect(screen.getByRole('textbox').getAttribute('aria-labelledby')).toEqual('jonsnow'); | ||
}); | ||
|
||
it('should have the given ariaDescribedBy', () => { | ||
let value = createEmptyValue(); | ||
render(<RichTextEditor value={value} ariaDescribedBy="sunandmoon" />); | ||
expect(screen.getByRole('textbox').getAttribute('aria-describedby')).toEqual('sunandmoon'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.