Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .bitmap
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ui/button": {
"name": "ui/button",
"scope": "automations.design",
"version": "0.0.7",
"version": "c2f7b3e45b5a5f67719c25188f6072e33e8a8f29",
"mainFile": "index.ts",
"rootDir": "bit-components/design/ui/button"
},
Expand All @@ -51,5 +51,12 @@
"mainFile": "index.ts",
"rootDir": "bit-components/design/ui/input"
},
"$schema-version": "17.0.0"
"$schema-version": "17.0.0",
"_bit_lane": {
"id": {
"name": "update-button-tests",
"scope": "automations.design"
},
"exported": true
}
}
24 changes: 21 additions & 3 deletions bit-components/design/ui/button/button.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import { Button } from './button.js';
import { vi } from 'vitest';
import { Button } from './button.js';

describe('Button', () => {
it('renders children correctly', () => {
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('Button', () => {
});

it('renders icon correctly', () => {
const icon = <span data-testid="test-icon">🚀</span>;
const icon = <span data-testid="test-icon" role="img" aria-label="Rocket">🚀</span>;
render(<Button icon={icon}>Click me</Button>);
expect(screen.getByTestId('test-icon')).toBeInTheDocument();
});
Expand All @@ -68,7 +68,7 @@ describe('Button', () => {
});

it('hides icons when in loading state', () => {
const icon = <span data-testid="test-icon">🚀</span>;
const icon = <span data-testid="test-icon" role="img" aria-label="Rocket">🚀</span>;
render(<Button loading icon={icon}>Click me</Button>);
expect(screen.queryByTestId('test-icon')).not.toBeInTheDocument();
});
Expand All @@ -88,4 +88,22 @@ describe('Button', () => {
rerender(<Button type="reset">Button</Button>);
expect(screen.getByRole('button')).toHaveAttribute('type', 'reset');
});

it('applies multiple props correctly when combined', () => {
render(
<Button
variant="danger"
size="large"
data-testid="combined-button"
>
Delete Item
</Button>
);

const button = screen.getByTestId('combined-button');
expect(button).toHaveClass('danger');
expect(button).toHaveClass('large');
expect(button).toHaveAttribute('type', 'button'); // default type
expect(screen.getByText('Delete Item')).toBeInTheDocument();
});
});