Skip to content

Commit

Permalink
Make test id constant
Browse files Browse the repository at this point in the history
Signed-off-by: Olusegun Akintayo <akintayo.segun@gmail.com>
  • Loading branch information
segun committed Jun 15, 2023
1 parent a48bf1f commit a4969ea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { BannerVariant } from './Banner.types';
import { ButtonVariants } from '../../Buttons/Button';
import { IconName } from '../../Icons/Icon';
import { ButtonIconSizes, ButtonIconVariants } from '../../Buttons/ButtonIcon';
import { TESTID_BANNER_CLOSE_BUTTON_ICON } from './foundation/BannerBase/BannerBase.constants';

describe('Banner', () => {
it('should render correctly', () => {
Expand Down Expand Up @@ -87,6 +88,8 @@ describe('Banner', () => {

expect(wrapper).toMatchSnapshot();
expect(await wrapper.findByText('Test Action Button')).toBeDefined();
expect(await wrapper.queryByTestId('banner-close-button')).toBeDefined();
expect(
await wrapper.queryByTestId(TESTID_BANNER_CLOSE_BUTTON_ICON),
).toBeDefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ exports[`Banner should render correctly with a close button 1`] = `
<TouchableOpacity
accessible={true}
activeOpacity={0.5}
data-testid="banner-close-button"
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
Expand All @@ -205,6 +204,7 @@ exports[`Banner should render correctly with a close button 1`] = `
"width": 24,
}
}
testID="banner-close-button-icon"
>
<SvgMock
color="#0376C9"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import { SAMPLE_ICON_PROPS } from '../../../../Icons/Icon/Icon.constants';
// Internal dependencies.
import { BannerBaseProps } from './BannerBase.types';

// Test IDs
export const TESTID_BANNER_CLOSE_BUTTON_ICON = 'banner-close-button-icon';

// Defaults
export const DEFAULT_BANNERBASE_TITLE_TEXTVARIANT = TextVariant.BodyLGMedium;
export const DEFAULT_BANNERBASE_DESCRIPTION_TEXTVARIANT = TextVariant.BodyMD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
DEFAULT_BANNERBASE_CLOSEBUTTON_BUTTONICONVARIANT,
DEFAULT_BANNERBASE_CLOSEBUTTON_BUTTONICONSIZE,
DEFAULT_BANNERBASE_CLOSEBUTTON_ICONNAME,
TESTID_BANNER_CLOSE_BUTTON_ICON,
} from './BannerBase.constants';

const BannerBase: React.FC<BannerBaseProps> = ({
Expand Down Expand Up @@ -69,7 +70,7 @@ const BannerBase: React.FC<BannerBaseProps> = ({
{(onClose || closeButtonProps) && (
<View style={styles.endAccessory}>
<ButtonIcon
data-testid="banner-close-button"
testID={TESTID_BANNER_CLOSE_BUTTON_ICON}
variant={DEFAULT_BANNERBASE_CLOSEBUTTON_BUTTONICONVARIANT}
size={DEFAULT_BANNERBASE_CLOSEBUTTON_BUTTONICONSIZE}
onPress={onClose || closeButtonProps?.onPress || noop}
Expand Down

0 comments on commit a4969ea

Please sign in to comment.