Skip to content

Commit 1e7ab28

Browse files
committed
Test disabled Buttons for all variants
1 parent 8dd1ce7 commit 1e7ab28

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/components/Button/Button.spec.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { render, fireEvent } from '@testing-library/react'
33

44
import { renderWithTheme, theme } from '../../../test/utils'
55
import { blockSizes } from '../common/system'
6+
import { createDisabledTextStyles } from '../common'
67

78
import Button from './Button'
89

@@ -36,11 +37,21 @@ describe('<Button />', () => {
3637
expect(onButtonClick).toHaveBeenCalled()
3738
})
3839

39-
it('should render disabled', () => {
40-
const { getByRole } = renderWithTheme(<Button {...defaultProps} disabled />)
40+
it('should handle disabled for all variants', () => {
41+
const { getByRole, rerender } = renderWithTheme(<Button {...defaultProps} disabled />)
4142
const button = getByRole('button')
43+
const disabledTextShadow = `1px 1px ${theme.textDisabledShadow}`
4244

4345
expect(button).toHaveStyleRule('color', theme.textDisabled)
46+
expect(button).toHaveStyleRule('text-shadow', disabledTextShadow)
47+
48+
rerender(<Button {...defaultProps} variant='menu' />)
49+
expect(button).toHaveStyleRule('color', theme.textDisabled)
50+
expect(button).toHaveStyleRule('text-shadow', disabledTextShadow)
51+
52+
rerender(<Button {...defaultProps} variant='flat' />)
53+
expect(button).toHaveStyleRule('color', theme.textDisabled)
54+
expect(button).toHaveStyleRule('text-shadow', disabledTextShadow)
4455
})
4556

4657
it('should handle fullWidth prop', () => {

0 commit comments

Comments
 (0)