Skip to content

Commit

Permalink
Grouped tests with default (primary) variant
Browse files Browse the repository at this point in the history
  • Loading branch information
narin committed Nov 16, 2023
1 parent ce5d3a5 commit c1ccd01
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions packages/components/src/components/Button/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,25 @@ describe('Button', () => {
const label = 'Button text'
const onPressSpy = jest.fn()

it('initializes correctly', async () => {
component = render(<Button label={label} onPress={onPressSpy} />)
expect(component).toBeTruthy()
})
describe('Primary variant', () => {
beforeEach(() => {
component = render(<Button label={label} onPress={onPressSpy} />)
})

it('should call onChange', async () => {
component = render(<Button label={label} onPress={onPressSpy} />)
fireEvent.press(component.getByRole('button'))
expect(onPressSpy).toBeCalled()
})
it('initializes correctly', async () => {
expect(component).toBeTruthy()
})

it('should render label', async () => {
component = render(<Button label={label} onPress={onPressSpy} />)
expect(component.findByText('Button text')).toBeTruthy()
})
it('should call onChange', async () => {
fireEvent.press(component.getByRole('button'))
expect(onPressSpy).toBeCalled()
})

describe('Primary variant', () => {
it('should render Primary variant by default', async () => {
component = render(<Button label={label} onPress={onPressSpy} />)
it('should render label', async () => {
expect(component.findByText('Button text')).toBeTruthy()
})

it('should render Primary variant by default', async () => {
const button = component.getByRole('button')
const text = component.getByText(label)
const { backgroundColor, borderWidth } = button.props.style
Expand Down

0 comments on commit c1ccd01

Please sign in to comment.