Skip to content

Commit c8ed443

Browse files
committedAug 28, 2021
feat(scatterplot): add unit test for aria props
1 parent dda2edf commit c8ed443

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed
 

‎packages/scales/tests/compute.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import {
2+
ScaleAxis,
23
generateSeriesAxis,
34
stackAxis,
45
// computeAxisSlices,
56
computeXYScalesForSeries,
7+
// @ts-ignore
68
} from '../src'
79

8-
const axes = ['x', 'y']
10+
const axes: ScaleAxis[] = ['x', 'y']
911

1012
describe('generateSeriesAxis', () => {
1113
const pointScaleExpectation = {

‎packages/scatterplot/src/ScatterPlot.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ const InnerScatterPlot = <RawDatum extends ScatterPlotDatum>({
4949
markers = svgDefaultProps.markers,
5050
legends = svgDefaultProps.legends,
5151
role = svgDefaultProps.role,
52+
ariaLabel,
53+
ariaLabelledBy,
54+
ariaDescribedBy,
5255
}: InnerScatterPlotProps<RawDatum>) => {
5356
const { margin, innerWidth, innerHeight, outerWidth, outerHeight } = useDimensions(
5457
width,
@@ -194,7 +197,15 @@ const InnerScatterPlot = <RawDatum extends ScatterPlotDatum>({
194197
}
195198

196199
return (
197-
<SvgWrapper width={outerWidth} height={outerHeight} margin={margin} role={role}>
200+
<SvgWrapper
201+
width={outerWidth}
202+
height={outerHeight}
203+
margin={margin}
204+
role={role}
205+
ariaLabel={ariaLabel}
206+
ariaLabelledBy={ariaLabelledBy}
207+
ariaDescribedBy={ariaDescribedBy}
208+
>
198209
{layers.map((layer, i) => {
199210
if (typeof layer === 'string' && layerById[layer] !== undefined) {
200211
return layerById[layer]

‎packages/scatterplot/tests/ScatterPlot.test.tsx

+18-1
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,21 @@ describe('annotations', () => {
382382
it('should support markers', () => {})
383383
})
384384

385-
describe('accessibility', () => {})
385+
describe('accessibility', () => {
386+
it('should forward root aria properties to the SVG element', () => {
387+
const wrapper = mount(
388+
<ScatterPlot<TestDatum>
389+
{...baseProps}
390+
ariaLabel="AriaLabel"
391+
ariaLabelledBy="AriaLabelledBy"
392+
ariaDescribedBy="AriaDescribedBy"
393+
/>
394+
)
395+
396+
const svg = wrapper.find('svg')
397+
398+
expect(svg.prop('aria-label')).toBe('AriaLabel')
399+
expect(svg.prop('aria-labelledby')).toBe('AriaLabelledBy')
400+
expect(svg.prop('aria-describedby')).toBe('AriaDescribedBy')
401+
})
402+
})

‎packages/stream/tests/Stream.test.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { mount } from 'enzyme'
2+
// @ts-ignore
23
import { Stream, StreamLayerData, StreamLayerDatum, StreamSliceData, StreamSvgProps } from '../src'
34

45
type TestDatum = {

0 commit comments

Comments
 (0)
Please sign in to comment.