Files
nimbus/resources/js/tests/components/base/AppButton.test.ts
Mazen Touati 6ba071dc98 test: front-end tests cleanup (round 1)
the aim is to make the tests more about the behavior rather than implementation, add some missing tests, and improve the code.
2025-11-16 19:03:40 +01:00

39 lines
1.3 KiB
TypeScript

import { AppButton } from '@/components/base/button';
import { renderWithProviders, screen } from '@/tests/_utils/test-utils';
import { describe, expect, it } from 'vitest';
describe('AppButton', () => {
it('applies default sizing and variant styles', () => {
renderWithProviders(AppButton, { slots: { default: 'Submit' } });
const button = screen.getByRole('button', { name: 'Submit' });
expect(button.className).toContain('bg-zinc-900');
expect(button.className).toContain('h-9');
});
it('applies requested variant styles', () => {
renderWithProviders(AppButton, {
props: { variant: 'destructive' },
slots: { default: 'Delete' },
});
const button = screen.getByRole('button', { name: 'Delete' });
expect(button.className).toContain('bg-red-500');
expect(button.className).toContain('dark:bg-red-900');
});
it('merges custom classes with size styles', () => {
renderWithProviders(AppButton, {
props: { size: 'lg', class: 'tracking-wide' },
slots: { default: 'Large' },
});
const button = screen.getByRole('button', { name: 'Large' });
expect(button.className).toContain('h-10');
expect(button.className).toContain('tracking-wide');
});
});