summaryrefslogtreecommitdiff
path: root/src/components/ui/alert.test.tsx
diff options
context:
space:
mode:
authorBertrand Yuan <noreply@bertyuan.com>2026-03-26 00:02:16 +0800
committerBertrand Yuan <noreply@bertyuan.com>2026-03-26 00:02:16 +0800
commit8a6a6712e7554f110b5ef951f270d88fd010e040 (patch)
tree12cb86b1ede55e15600ef7f139ef7ec91b9fa8a1 /src/components/ui/alert.test.tsx
parentf7a02fe0e112cf108fc5f22872f1efc077e99fe8 (diff)
add more tests
Diffstat (limited to 'src/components/ui/alert.test.tsx')
-rw-r--r--src/components/ui/alert.test.tsx30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/components/ui/alert.test.tsx b/src/components/ui/alert.test.tsx
new file mode 100644
index 0000000..ded0356
--- /dev/null
+++ b/src/components/ui/alert.test.tsx
@@ -0,0 +1,30 @@
+import { render, screen } from '@testing-library/react';
+import { describe, expect, test } from 'vitest';
+import { Alert, AlertDescription, AlertTitle } from './alert';
+
+describe('Alert', () => {
+ test('renders with role and slot attributes', () => {
+ render(
+ <Alert>
+ <AlertTitle>Heads up</AlertTitle>
+ <AlertDescription>Something happened.</AlertDescription>
+ </Alert>,
+ );
+
+ const alert = screen.getByRole('alert');
+ expect(alert).toHaveAttribute('data-slot', 'alert');
+ expect(screen.getByText('Heads up')).toHaveAttribute('data-slot', 'alert-title');
+ expect(screen.getByText('Something happened.')).toHaveAttribute(
+ 'data-slot',
+ 'alert-description',
+ );
+ });
+
+ test('applies destructive variant classes', () => {
+ render(<Alert variant='destructive'>Danger</Alert>);
+
+ const alert = screen.getByRole('alert');
+ expect(alert.className).toContain('text-destructive');
+ });
+});
+