mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 06:07:06 +01:00
1007930078
* text housekeeping * update testing * Text constant * TEXT const to story * format text sizes * add associated constants to text component * add all exports to global index.js * update snapshot * update text component variants * Update ui/components/component-library/text/README.mdx Co-authored-by: George Marshall <george.marshall@consensys.net> * update rearrangements * update text in tests Co-authored-by: George Marshall <george.marshall@consensys.net>
50 lines
2.0 KiB
JavaScript
50 lines
2.0 KiB
JavaScript
/* eslint-disable jest/require-top-level-describe */
|
|
import { render } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { COLORS } from '../../../helpers/constants/design-system';
|
|
import { Icon, ICON_NAMES } from '../icon';
|
|
|
|
import { HelpText } from './help-text';
|
|
|
|
describe('HelpText', () => {
|
|
it('should render with text inside the HelpText', () => {
|
|
const { getByText, container } = render(<HelpText>help text</HelpText>);
|
|
expect(getByText('help text')).toBeDefined();
|
|
expect(getByText('help text')).toHaveClass('mm-help-text');
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
it('should render with and additional className', () => {
|
|
const { getByText } = render(
|
|
<HelpText className="test-class">help text</HelpText>,
|
|
);
|
|
expect(getByText('help text')).toHaveClass('mm-help-text test-class');
|
|
});
|
|
it('should render with react nodes inside the HelpText', () => {
|
|
const { getByText, getByTestId } = render(
|
|
<HelpText>
|
|
help text <Icon name={ICON_NAMES.WARNING_FILLED} data-testid="icon" />
|
|
</HelpText>,
|
|
);
|
|
expect(getByText('help text')).toBeDefined();
|
|
expect(getByTestId('icon')).toBeDefined();
|
|
});
|
|
it('should render with error state', () => {
|
|
const { getByText } = render(<HelpText error>error</HelpText>);
|
|
expect(getByText('error')).toHaveClass('mm-text--color-error-default');
|
|
});
|
|
it('should render with different colors', () => {
|
|
const { getByText } = render(
|
|
<>
|
|
<HelpText>default</HelpText>
|
|
<HelpText color={COLORS.WARNING_DEFAULT}>warning</HelpText>
|
|
<HelpText color={COLORS.SUCCESS_DEFAULT}>success</HelpText>
|
|
<HelpText color={COLORS.INFO_DEFAULT}>info</HelpText>
|
|
</>,
|
|
);
|
|
expect(getByText('default')).toHaveClass('mm-text--color-text-default');
|
|
expect(getByText('warning')).toHaveClass('mm-text--color-warning-default');
|
|
expect(getByText('success')).toHaveClass('mm-text--color-success-default');
|
|
expect(getByText('info')).toHaveClass('mm-text--color-info-default');
|
|
});
|
|
});
|