mirror of https://github.com/kremalicious/blog.git
22 lines
617 B
TypeScript
22 lines
617 B
TypeScript
import React from 'react'
|
|
import { render, fireEvent } from '@testing-library/react'
|
|
|
|
import InputGroup from './InputGroup'
|
|
|
|
const setAmount = jest.fn()
|
|
|
|
describe('InputGroup', () => {
|
|
it('renders without crashing', async () => {
|
|
const { container } = render(
|
|
<InputGroup amount="1" setAmount={setAmount} />
|
|
)
|
|
expect(container.firstChild).toBeInTheDocument()
|
|
|
|
const input = container.querySelector('input')
|
|
const button = container.querySelector('button')
|
|
fireEvent.change(input, { target: { value: '3' } })
|
|
fireEvent.click(button)
|
|
expect(setAmount).toHaveBeenCalled()
|
|
})
|
|
})
|