This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test: add test for DataTag component (#2858)
* Test: add test for DataTag component * Test: assert background color for DataTag component Co-authored-by: Monica Kristiadi <monica.kristiadi@tech.jago.com> Co-authored-by: Manish Kumar ⛄ <manishprivet@protonmail.com> Co-authored-by: Claudio Wunder <cwunder@gnome.org>
- Loading branch information
1 parent
3d30947
commit d5e74eb
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/components/DataTag/__tests__/__snapshots__/index.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); |