-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
13 changed files
with
2,191 additions
and
994 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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import { describe, expect, it } from 'vitest' | ||
|
||
import { Button } from './button' | ||
|
||
describe('Button', () => { | ||
it('renders correctly with default props', () => { | ||
render(<Button>Click me</Button>) | ||
const button = screen.getByRole('button', { | ||
name: /click me/i, | ||
}) | ||
expect(button).toBeInTheDocument() | ||
expect(button).toHaveClass('bg-primary text-white') | ||
}) | ||
|
||
it('renders with primary variant and default size', () => { | ||
render(<Button variant="primary">Primary Button</Button>) | ||
const button = screen.getByRole('button', { | ||
name: /primary button/i, | ||
}) | ||
expect(button).toHaveClass('bg-primary text-white') | ||
}) | ||
|
||
it('renders with secondary variant', () => { | ||
render(<Button variant="secondary">Secondary Button</Button>) | ||
const button = screen.getByRole('button', { | ||
name: /secondary button/i, | ||
}) | ||
expect(button).toHaveClass('bg-shade-secondary-1 text-white') | ||
}) | ||
|
||
it('renders with outline variant', () => { | ||
render(<Button variant="outline">Outline Button</Button>) | ||
const button = screen.getByRole('button', { | ||
name: /outline button/i, | ||
}) | ||
expect(button).toHaveClass( | ||
'border border-primary text-primary', | ||
) | ||
}) | ||
|
||
it('renders with different sizes', () => { | ||
render(<Button size="sm">Small Button</Button>) | ||
const button = screen.getByRole('button', { | ||
name: /small button/i, | ||
}) | ||
expect(button).toHaveClass('h-8 px-3 text-xs') | ||
|
||
render(<Button size="lg">Large Button</Button>) | ||
const largeButton = screen.getByRole('button', { | ||
name: /large button/i, | ||
}) | ||
expect(largeButton).toHaveClass('h-10 px-8') | ||
}) | ||
|
||
it('renders with an icon on the left', () => { | ||
render( | ||
<Button icon={<span>Icon</span>}> | ||
Button with Icon | ||
</Button>, | ||
) | ||
const button = screen.getByRole('button', { | ||
name: /button with icon/i, | ||
}) | ||
expect(button).toContainHTML('<span>Icon</span>') | ||
}) | ||
|
||
it('renders with an icon on the right', () => { | ||
render( | ||
<Button icon={<span>Icon</span>} iconPosition="right"> | ||
Button with Icon | ||
</Button>, | ||
) | ||
const button = screen.getByRole('button', { | ||
name: /button with icon/i, | ||
}) | ||
expect(button).toContainHTML('<span>Icon</span>') | ||
}) | ||
|
||
it('renders as disabled', () => { | ||
render(<Button disabled>Disabled Button</Button>) | ||
const button = screen.getByRole('button', { | ||
name: /disabled button/i, | ||
}) | ||
expect(button).toBeDisabled() | ||
}) | ||
}) |
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
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
Oops, something went wrong.