diff --git a/components/Alert/Alert.tsx b/components/Alert/Alert.tsx index 80fc809f..fff2d4b8 100644 --- a/components/Alert/Alert.tsx +++ b/components/Alert/Alert.tsx @@ -9,13 +9,13 @@ const alertVariants = cva( { variants: { variant: { - default: 'bg-background text-foreground', + default: 'bg-muted text-muted-foreground', error: - 'bg-background text-error [&>svg]:text-error text-error border-error', + 'bg-muted text-error [&>svg]:text-error text-error border-error', warning: - 'bg-background text-warning [&>svg]:text-warning text-warning border-warning', + 'bg-muted text-warning [&>svg]:text-warning text-warning border-warning', success: - 'bg-background text-success [&>svg]:text-success text-success border-success', + 'bg-muted text-success [&>svg]:text-success text-success border-success', }, }, defaultVariants: { diff --git a/components/AlertNotification/AlertNotification.test.tsx b/components/AlertNotification/AlertNotification.test.tsx index 0d307594..39555f5e 100644 --- a/components/AlertNotification/AlertNotification.test.tsx +++ b/components/AlertNotification/AlertNotification.test.tsx @@ -1,8 +1,9 @@ -import React from 'react'; -import { render } from '@testing-library/react'; import Alert from './AlertNotification'; import { AlertVariants } from './Alerts.enum'; import { CheckCircle, XCircle, Info, AlertTriangle } from 'lucide-react'; +import React from 'react'; +import { render, screen, fireEvent} from '@testing-library/react'; +import toast from 'react-hot-toast'; const variantTestCases = { [AlertVariants.Success]: { @@ -30,7 +31,36 @@ const variantTestCases = { describe('AlertNotification', () => { for (const [key, value] of Object.entries(variantTestCases)) { it(`renders the correct variant ${key}`, () => { - render(); + render( + , + ); + }); + + it('should render the dismiss button on each alert type', () => { + render( + , + ); + const dismissButton = screen.getByTestId('dismiss-alert-btn'); + expect(dismissButton).toBeInTheDocument(); + }); + + it('should fire the toast.remove() function when dismiss button is clicked', async () => { + const spyToast = jest.spyOn(toast, 'remove'); + render( + , + ); + const dismissButton = screen.getByTestId('dismiss-alert-btn'); + fireEvent.click(dismissButton); + expect(spyToast).toHaveBeenCalled(); }); - } + }; }); diff --git a/components/AlertNotification/AlertNotification.tsx b/components/AlertNotification/AlertNotification.tsx index fb07b49b..95020f32 100644 --- a/components/AlertNotification/AlertNotification.tsx +++ b/components/AlertNotification/AlertNotification.tsx @@ -2,12 +2,14 @@ // Licensed under the MIT License. import { Alert as AlertDefault } from '../Alert/Alert'; -import { AlertTitle } from '../AlertTItle/AlertTitle'; import { AlertDescription } from '../AlertDescription/AlertDescription'; -import { JSX } from 'react'; -import { CheckCircle, XCircle, Info, AlertTriangle } from 'lucide-react'; -import { IAlertNotification } from './AlertNotification.interface'; +import { AlertTitle } from '../AlertTItle/AlertTitle'; import { AlertVariants } from './Alerts.enum'; +import { Button } from '../Button/Button'; +import { CheckCircle, XCircle, Info, AlertTriangle, X } from 'lucide-react'; +import { IAlertNotification } from './AlertNotification.interface'; +import { JSX } from 'react'; +import toast from 'react-hot-toast'; const variantConfig = { success: { @@ -46,6 +48,15 @@ const Alert = ({ +