Skip to content

Commit

Permalink
fix(PPDSC-2117): address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Xin00163 committed May 20, 2022
1 parent 718a2ee commit 2d12d9b
Show file tree
Hide file tree
Showing 3 changed files with 458 additions and 267 deletions.
27 changes: 25 additions & 2 deletions src/icon-button/__tests__/icon-button.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import React from 'react';
import {renderToFragmentWithTheme} from '../../test/test-utils';
import React, {createRef} from 'react';
import {act} from 'react-test-renderer';
import {
renderToFragmentWithTheme,
renderWithTheme,
} from '../../test/test-utils';
import {IconButton} from '..';
import {ButtonSize, IconButtonProps} from '../../button';
import {IconFilledEmail} from '../../icons';
Expand Down Expand Up @@ -73,4 +77,23 @@ describe('IconButton', () => {
const fragment = renderToFragmentWithTheme(renderIconButton, props);
expect(fragment).toMatchSnapshot();
});

test('focus can be triggered with ref', async () => {
const iconButtonRef = createRef<HTMLButtonElement>();

const props = {
ref: iconButtonRef,
'aria-label': 'Test icon button',
children: <IconFilledEmail />,
};

renderWithTheme(IconButton, props);

await act(async () => {
if (iconButtonRef && iconButtonRef.current) {
iconButtonRef.current.focus();
}
});
expect(iconButtonRef.current).toHaveFocus();
});
});
Loading

0 comments on commit 2d12d9b

Please sign in to comment.