Skip to content

Commit

Permalink
Add expectation around disabled selection via keyboard navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuatf committed Dec 14, 2022
1 parent 46fc6b3 commit 12953d0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/components/src/tab-panel/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ describe( 'TabPanel', () => {
expect( mockOnSelect ).toHaveBeenLastCalledWith( 'beta' );
} );

it( 'should disable the tab when `disabled` is true', () => {
it( 'should disable the tab when `disabled` is true', async () => {
const user = setupUser();
const mockOnSelect = jest.fn();

render(
Expand All @@ -183,6 +184,13 @@ describe( 'TabPanel', () => {
'aria-disabled',
'true'
);

// onSelect gets called on the initial render.
expect( mockOnSelect ).toHaveBeenCalledTimes( 1 );

// onSelect should not be called since the disabled tab is highlighted, but not selected.
await user.keyboard( '[ArrowLeft]' );
expect( mockOnSelect ).toHaveBeenCalledTimes( 1 );
} );

it( 'should select the first enabled tab when the inital tab is disabled', () => {
Expand Down

0 comments on commit 12953d0

Please sign in to comment.