Skip to content

Commit 0517d2c

Browse files
updated and added some tests
1 parent 6e544c8 commit 0517d2c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

packages/react/src/CounterLabel/CounterLabel.test.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,35 @@ describe('CounterLabel', () => {
2626
it('respects the primary "variant" prop', () => {
2727
const {container} = HTMLRender(<CounterLabel variant="primary">1234</CounterLabel>)
2828
expect(container.firstChild).toBeInTheDocument()
29-
expect(container.firstChild).toHaveTextContent('1234')
29+
expect(container.firstChild).toHaveAttribute('data-variant', 'primary')
3030
})
3131

3232
it('respects the secondary "variant" prop', () => {
3333
const {container} = HTMLRender(<CounterLabel variant="secondary">1234</CounterLabel>)
3434
expect(container.firstChild).toBeInTheDocument()
35-
expect(container.firstChild).toHaveTextContent('1234')
35+
expect(container.firstChild).toHaveAttribute('data-variant', 'secondary')
3636
})
3737

3838
it('respects the primary "scheme" prop', () => {
3939
const {container} = HTMLRender(<CounterLabel scheme="primary">1234</CounterLabel>)
4040
expect(container.firstChild).toBeInTheDocument()
41-
expect(container.firstChild).toHaveTextContent('1234')
41+
expect(container.firstChild).toHaveAttribute('data-variant', 'primary')
4242
})
4343

4444
it('renders with secondary variant when no "scheme" or "variant" prop is provided', () => {
4545
const {container} = HTMLRender(<CounterLabel>1234</CounterLabel>)
4646
expect(container.firstChild).toBeInTheDocument()
47-
expect(container.firstChild).toHaveTextContent('1234')
47+
expect(container.firstChild).toHaveAttribute('data-variant', 'secondary')
48+
})
49+
50+
it('prefer variant over "scheme" prop', () => {
51+
const {container} = HTMLRender(
52+
<CounterLabel scheme="secondary" variant="primary">
53+
1234
54+
</CounterLabel>,
55+
)
56+
expect(container.firstChild).toBeInTheDocument()
57+
expect(container.firstChild).toHaveAttribute('data-variant', 'primary')
4858
})
4959

5060
it('should render visually hidden span correctly for screen readers', () => {

0 commit comments

Comments
 (0)