forked from blakeblackshear/frigate
-
Notifications
You must be signed in to change notification settings - Fork 0
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
85776cc
commit a202c44
Showing
2 changed files
with
36 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { h } from 'preact'; | ||
import Button from '../Button'; | ||
import { render, screen } from '@testing-library/preact'; | ||
|
||
describe('Button', () => { | ||
test('renders children', async () => { | ||
render( | ||
<Button> | ||
<div>hello</div> | ||
<div>hi</div> | ||
</Button> | ||
); | ||
expect(screen.queryByText('hello')).toBeInTheDocument(); | ||
expect(screen.queryByText('hi')).toBeInTheDocument(); | ||
}); | ||
|
||
test('includes focus, active, and hover classes when enabled', async () => { | ||
render(<Button>click me</Button>); | ||
|
||
const classList = screen.queryByRole('button').classList; | ||
expect(classList.contains('focus:outline-none')).toBe(true); | ||
expect(classList.contains('focus:ring-2')).toBe(true); | ||
expect(classList.contains('hover:shadow-md')).toBe(true); | ||
expect(classList.contains('active:bg-blue-600')).toBe(true); | ||
}); | ||
|
||
test('does not focus, active, and hover classes when enabled', async () => { | ||
render(<Button disabled>click me</Button>); | ||
|
||
const classList = screen.queryByRole('button').classList; | ||
expect(classList.contains('focus:outline-none')).toBe(false); | ||
expect(classList.contains('focus:ring-2')).toBe(false); | ||
expect(classList.contains('hover:shadow-md')).toBe(false); | ||
expect(classList.contains('active:bg-blue-600')).toBe(false); | ||
}); | ||
}); |