Skip to content
Closed
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
18 changes: 18 additions & 0 deletions packages/fuselage/src/components/Button/Button.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,22 @@ describe('[IconButton Component]', () => {
const results = await axe(container);
expect(results).toHaveNoViolations();
});

it('should default to type="button" to prevent accidental form submissions', () => {
const { getByRole } = render(<Default />);
const button = getByRole('button');
expect(button).toHaveAttribute('type', 'button');
});

it('should allow overriding type attribute when explicitly passed', () => {
const { getByRole } = render(<Default type='submit' />);
const button = getByRole('button');
expect(button).toHaveAttribute('type', 'submit');
});

it('should render as anchor tag when is="a" prop is passed', () => {
const { getByRole } = render(<Default is='a' href='#' />);
const link = getByRole('link');
expect(link.tagName).toBe('A');
});
});