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 / NotificationMotdAlertView.test.tsx
NotificationMotdAlertView.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, SanitizeHtml: (html: string) => html }));
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 { NotificationMotdAlertView } = await import('./NotificationMotdAlertView');

afterEach(cleanup);

describe('NotificationMotdAlertView', () => {
    it('lists each message in its own box and closes with the button', () => {
        const onClose = vi.fn();
        const item = { title: 'Messages for you', messages: ['First news', 'Second news'] } as never;

        const { container } = render(<NotificationMotdAlertView item={item} onClose={onClose} />);

        expect(container.querySelectorAll('.octane-motd-item')).toHaveLength(2);
        expect(screen.getByText('Messages for you')).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