5180 fichiers 38.5 Mo 0 téléchargements 236 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / components / talent / TalentTrackView.test.tsx
TalentTrackView.test.tsx 2.2 Ko Télécharger le fichier
import { cleanup, render } from '@testing-library/react';
import { PropsWithChildren } from 'react';
import { afterEach, describe, expect, it, vi } from 'vitest';

vi.mock('../../api', async () => {
    const actual = await vi.importActual<typeof import('../../api')>('../../api');

    return {
        ...actual,
        GetConfigurationValue: (_key: string, fallback: unknown) => fallback,
        LocalizeBadgeDescription: () => 'Rate %limit% Helpers.',
        localizeWithFallback: (key: string, fallback: string) =>
            key === 'talent.track.helper.guide.begin.description' ? 'Help others.<br><br>You are on your way.' : fallback
    };
});

vi.mock('../../common', () => ({
    AirModalDialog: ({ children }: PropsWithChildren) => <div>{children}</div>,
    LayoutAvatarImageView: () => <div />,
    LayoutBadgeImageView: () => <div />
}));

vi.mock('../help/habbo-way/HabboWayPagerView', () => ({ LibraryImageView: () => <div /> }));

import { getTalentTaskInstruction, TalentTrackView, talentProgressPosition } from './TalentTrackView';

afterEach(cleanup);

describe('TalentTrackView', () => {
    it('draws the begin text as AIR formatted text, so <br> breaks the line', () => {
        const { container } = render(
            <TalentTrackView track={{ name: 'helper', levels: [] } as any} onClose={vi.fn()} onOpenTrack={vi.fn()} onSelectTask={vi.fn()} />
        );
        const text = container.querySelector('.octane-talent-begin__text');

        expect(text?.querySelectorAll('br')).toHaveLength(2);
        expect(text?.textContent).toBe('Help others.You are on your way.');
    });

    it('places the progress needle inside the inset AIR keeps at both ends of the bar', () => {
        expect(talentProgressPosition(0)).toBe('calc(52px + (100% - 104px) * 0)');
        expect(talentProgressPosition(0.5)).toBe('calc(52px + (100% - 104px) * 0.5)');
        expect(talentProgressPosition(2)).toBe('calc(52px + (100% - 104px) * 1)');
    });

    it('fills the %limit% the badge texts leave open with the task goal', () => {
        expect(getTalentTaskInstruction('ACH_GuideFeedbackGiver1', 5)).toBe('Rate 5 Helpers.');
        expect(getTalentTaskInstruction('ACH_GuideFeedbackGiver1')).toBe('Rate %limit% Helpers.');
    });
});
15Sujets
1Dépôts
20Membres
2En 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