Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Test: add test for DataTag component #2858

Merged
merged 8 commits into from Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/components/DataTag/__tests__/__snapshots__/index.test.tsx.snap
@@ -0,0 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Data Tag component renders with blue background color when tag is 'M' 1`] = `
<div>
<span
class="dataTag"
data-tag="M"
>
M
</span>
</div>
`;

exports[`Data Tag component renders with red background color when tag is 'E' 1`] = `
<div>
<span
class="dataTag"
data-tag="E"
>
E
</span>
</div>
`;

exports[`Data Tag component renders with yellow background color when tag is 'C' 1`] = `
<div>
<span
class="dataTag"
data-tag="C"
>
C
</span>
</div>
`;
27 changes: 27 additions & 0 deletions src/components/DataTag/__tests__/index.test.tsx
@@ -0,0 +1,27 @@
import { render } from '@testing-library/react';
import React from 'react';

import DataTag from '..';

describe('Data Tag component', () => {
it(`renders with red background color when tag is 'E'`, () => {
const { container } = render(<DataTag tag="E" />);

expect(container).toHaveStyle('background-color: var(--danger6)');
expect(container).toMatchSnapshot();
});

it(`renders with yellow background color when tag is 'C'`, () => {
const { container } = render(<DataTag tag="C" />);

expect(container).toHaveStyle('background-color: var(--warning4)');
expect(container).toMatchSnapshot();
});

it(`renders with blue background color when tag is 'M'`, () => {
const { container } = render(<DataTag tag="M" />);

expect(container).toHaveStyle('background-color: var(--info6)');
expect(container).toMatchSnapshot();
});
});