Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit a6cf7ef

Browse files
committed
test(tag): refactor use screen
1 parent 99f38b2 commit a6cf7ef

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed
Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CBox, CTag, CTagLabel, CTagIcon, CTagCloseButton, CAvatar } from '../..'
2-
import { render } from '@/tests/test-utils'
2+
import { render, screen } from '@/tests/test-utils'
33

44
const renderComponent = (props) => {
55
const base = {
@@ -22,38 +22,36 @@ it('should render correctly', () => {
2222
})
2323

2424
it('should display children', () => {
25-
const { getByText } = renderComponent()
25+
renderComponent()
2626

27-
expect(getByText('Green')).toBeInTheDocument()
27+
expect(screen.getByText('Green')).toBeInTheDocument()
2828
})
2929

3030
it('should display tag with right icon', () => {
3131
const { asFragment } = renderComponent({
3232
template: `
33-
<CBox mb="3">
34-
<CTag size="sm" variantColor="green">
35-
<CTagLabel>Green</CTagLabel>
36-
<CTagIcon icon="add" size="12px" />
37-
</CTag>
38-
</CBox>
39-
`
33+
<CBox mb="3">
34+
<CTag size="sm" variantColor="green">
35+
<CTagLabel>Green</CTagLabel>
36+
<CTagIcon icon="add" size="12px" />
37+
</CTag>
38+
</CBox>`
4039
})
4140
expect(asFragment()).toMatchSnapshot()
4241
})
4342
it('should display tag with custom element', () => {
4443
const { asFragment } = renderComponent({
4544
template: `
46-
<CBox mb="3">
47-
<CTag rounded="full" variantColor="red">
48-
<CAvatar
49-
name="Mesut Koca"
50-
size="xs"
51-
src="https://pbs.twimg.com/profile_images/953743486842474496/cOrUdK4z_200x200.jpg"
52-
/>
53-
<CTagLabel>Mesut</CTagLabel>
54-
</CTag>
55-
</CBox>
56-
`
45+
<CBox mb="3">
46+
<CTag rounded="full" variantColor="red">
47+
<CAvatar
48+
name="Mesut Koca"
49+
size="xs"
50+
src="https://pbs.twimg.com/profile_images/953743486842474496/cOrUdK4z_200x200.jpg"
51+
/>
52+
<CTagLabel>Mesut</CTagLabel>
53+
</CTag>
54+
</CBox>`
5755
})
5856
expect(asFragment()).toMatchSnapshot()
5957
})

0 commit comments

Comments
 (0)