Skip to content

Commit

Permalink
test: add coverage for aria-label on handle container element
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdyman committed Feb 8, 2024
1 parent 54a715c commit 7db4b7c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/storybook/content/stories/99-tests/default.test.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@ Default.args = getArgs();

Default.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
const sliderRoot = canvas.queryByTestId(Default.args?.['data-testid']) as Element;
const sliderRoot = (await canvas.findByRole('slider')) as HTMLDivElement;

// Should have elements on mount.
await new Promise((resolve) => setTimeout(resolve, 500));
await waitFor(() => expect(sliderRoot).toBeInTheDocument());
await waitFor(() => expect(canvas.getByAltText('one')).toBeInTheDocument());
await waitFor(() => expect(canvas.getByAltText('two')).toBeInTheDocument());

// Should have a11y attributes on mount.
await waitFor(() => expect(sliderRoot).toHaveAttribute('aria-valuemin', '0'));
await waitFor(() => expect(sliderRoot).toHaveAttribute('aria-valuemax', '100'));
await waitFor(() => expect(sliderRoot).toHaveAttribute('aria-valuenow', '50'));
await waitFor(() =>
expect(canvas.queryByLabelText('Drag to move or focus and use arrow keys')).toBeInTheDocument(),
);

// Should have initial position on mount.
await waitFor(() => expect(Default.args?.onPositionChange).toHaveBeenLastCalledWith(50));
};

0 comments on commit 7db4b7c

Please sign in to comment.