Skip to content

Commit

Permalink
update test to account for tabbing
Browse files Browse the repository at this point in the history
  • Loading branch information
eburdekin committed Aug 12, 2024
1 parent b0de32e commit 14b0a01
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions products/statement-generator/src/tests/textareas.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,19 @@ describe('Textarea component', () => {
expect(label).toBeInTheDocument();
expect(label).toHaveAttribute('for', 'accessible-textarea');

// textarea is focusable
// textarea and label focus on tab
const input = getByPlaceholderText('Type here');
userEvent.click(input);
userEvent.tab();
expect(label).toHaveFocus();
userEvent.tab();
expect(input).toHaveFocus();

// textarea does not trap focus
userEvent.tab();
expect(input).not.toHaveFocus();

// textarea focuses on click
userEvent.click(input);
expect(input).toHaveFocus();
});
});

0 comments on commit 14b0a01

Please sign in to comment.