1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00

tag component housekeeping (#16355)

* tag component housekeeping

* added snapshot testing
This commit is contained in:
Nidhi Kumari 2022-11-04 01:48:16 +05:30 committed by GitHub
parent 8bdf820c70
commit 58da1d8075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 4 deletions

View File

@ -19,3 +19,7 @@ The `Tag` accepts all props below as well as all [Box](/docs/ui-components-ui-bo
### Label
The text content of the `Tag` component
<Canvas>
<Story id="ui-components-component-library-tag-tag-stories-js--label" />
</Canvas>

View File

@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Tag should render the label inside the tag and match snapshot 1`] = `
<div>
<div
class="box mm-tag box--padding-right-1 box--padding-left-1 box--display-inline-block box--flex-direction-row box--justify-content-center box--align-items-center box--background-color-background-default box--rounded-pill box--border-color-border-default box--border-width-1 box--border-style-solid"
data-testid="tag"
>
<p
class="box text text--body-sm text--color-text-default box--flex-direction-row"
>
Imported
</p>
</div>
</div>
`;

View File

@ -15,7 +15,7 @@ import {
export const Tag = ({ label, className, labelProps, ...props }) => {
return (
<Box
className={classnames('tag', className)}
className={classnames('mm-tag', className)}
backgroundColor={COLORS.BACKGROUND_DEFAULT}
borderColor={COLORS.BORDER_DEFAULT}
borderWidth={1}
@ -47,4 +47,8 @@ Tag.propTypes = {
* Additional classNames to be added to the Tag component
*/
className: PropTypes.string,
/**
* Tag also accepts all props from Box
*/
...Box.propTypes,
};

View File

@ -1,4 +1,4 @@
.tag {
.mm-tag {
height: auto;
width: max-content;
padding-top: 1px;

View File

@ -24,3 +24,9 @@ export default {
export const DefaultStory = (args) => <Tag {...args} />;
DefaultStory.storyName = 'Default';
export const Label = (args) => <Tag {...args}>Anchor Element</Tag>;
Label.args = {
label: 'Label Story',
};

View File

@ -5,9 +5,12 @@ import React from 'react';
import { Tag } from './tag';
describe('Tag', () => {
it('should render the label inside the tag', () => {
const { getByTestId } = render(<Tag data-testid="tag" label="Imported" />);
it('should render the label inside the tag and match snapshot', () => {
const { getByTestId, container } = render(
<Tag data-testid="tag" label="Imported" />,
);
expect(getByTestId('tag')).toBeDefined();
expect(getByTestId('tag')).toHaveTextContent('Imported');
expect(container).toMatchSnapshot();
});
});