5180 fichiers 38.5 Mo 0 téléchargements 474 vues mis à jour il y a 7 heures ui
nitro-v36-with-renderer-v36 / src / components / notification-center / views / alert-layouts / NotificationAbusiveAlertView.test.tsx
NotificationAbusiveAlertView.test.tsx 1.4 Ko Télécharger le fichier
import { cleanup, fireEvent, render, screen } from '@testing-library/react';
import { ReactNode } from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';

vi.mock('../../../../api', () => ({ LocalizeText: (key: string) => key, localizeWithFallback: (_key: string, fallback: string) => fallback }));
vi.mock('../../../../common', () => ({
    Button: (props: { children: ReactNode; onClick: () => void }) => <button onClick={props.onClick}>{props.children}</button>,
    LayoutNotificationAlertView: (props: { children: ReactNode; title: string; classNames: string[] }) => (
        <div className={props.classNames.join(' ')}>
            <h1>{props.title}</h1>
            {props.children}
        </div>
    )
}));

const { NotificationAbusiveAlertView } = await import('./NotificationAbusiveAlertView');

afterEach(cleanup);

describe('NotificationAbusiveAlertView', () => {
    it('shows the heading and the explanation and closes with its button', () => {
        const onClose = vi.fn();
        const item = { title: 'Your urgent request', messages: ['Too many calls.'] } as never;

        render(<NotificationAbusiveAlertView item={item} onClose={onClose} />);

        expect(screen.getByText('Bad news!')).toBeTruthy();
        expect(screen.getByText('Too many calls.')).toBeTruthy();

        fireEvent.click(screen.getByText('generic.close'));

        expect(onClose).toHaveBeenCalledTimes(1);
    });
});
15Sujets
1Dépôts
20Membres
3En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser