Skip to content

Commit

Permalink
test : Adds test for Badge (#125)
Browse files Browse the repository at this point in the history
Co-authored-by: sowmya198 <[email protected]>
  • Loading branch information
sowmya-AS and sowmya-AS authored Oct 31, 2023
1 parent a39f5b6 commit ddb9c4f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/packages/Badge/__snapshots__/test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Badge /> should render Badge with custom size, shape, and color 1`] = `
.c0 {
display: inline-block;
border-radius: 50%;
font-size: 1.8rem;
padding: 0.8rem 1.6rem;
background-color: red;
color: #F8F7FB;
}
<div>
<div
class="c0"
color="red"
shape="circle"
>
New
</div>
</div>
`;

exports[`<Badge /> should render Badge with default props 1`] = `
.c0 {
display: inline-block;
border-radius: 0;
font-size: 1.6rem;
padding: 0.8rem 1.6rem;
background-color: #022B54;
color: #F8F7FB;
}
<div>
<div
class="c0"
shape="square"
>
5
</div>
</div>
`;
25 changes: 25 additions & 0 deletions src/packages/Badge/test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react'
import { render } from '../../utils/testUtils'

import Badge from '.'

describe('<Badge />', () => {
it('should render Badge with default props', () => {
const { container } = render(<Badge content="5" />)
expect(container).toMatchSnapshot()
})

it('should render Badge with custom size, shape, and color', () => {
const { container } = render(
<Badge content="New" size="large" shape="circle" color="red" />
)
expect(container).toMatchSnapshot()
})
it('should render Badge by handling custom props correctly', () => {
const { getByTestId } = render(
<Badge data-testid="custom-badge" title="Custom Title" content="Custom" />
)
const badge = getByTestId('custom-badge')
expect(badge).toHaveAttribute('title', 'Custom Title')
})
})

0 comments on commit ddb9c4f

Please sign in to comment.