-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6d5e50
commit d31feb1
Showing
2 changed files
with
11 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
import { fireEvent, render, screen } from '@testing-library/react' | ||
import { describe, it, expect, vi } from 'vitest' | ||
import { describe, it, expect } from 'vitest' | ||
import { InputGroup } from '.' | ||
|
||
const setAmount = vi.fn() | ||
|
||
describe('InputGroup', () => { | ||
it('renders without crashing', async () => { | ||
render(<InputGroup amount="1" setAmount={setAmount} isDisabled={false} />) | ||
render(<InputGroup isDisabled={false} error={undefined} />) | ||
|
||
const input = await screen.findByRole('textbox') | ||
const button = await screen.findByRole('button') | ||
fireEvent.change(input, { target: { value: '3' } }) | ||
fireEvent.click(button) | ||
expect(setAmount).toHaveBeenCalled() | ||
}) | ||
|
||
it('renders disabled', async () => { | ||
render(<InputGroup amount="1" setAmount={setAmount} isDisabled={true} />) | ||
render(<InputGroup isDisabled={true} error={undefined} />) | ||
|
||
const input = await screen.findByRole('textbox') | ||
expect(input).toBeDefined() | ||
expect(input.attributes.getNamedItem('disabled')).toBeDefined() | ||
}) | ||
|
||
it('renders error', async () => { | ||
render(<InputGroup isDisabled={false} error={'Hello Error'} />) | ||
|
||
const errorItem = await screen.findByText('Hello Error') | ||
expect(errorItem).toBeDefined() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters