27 lines
936 B
TypeScript
27 lines
936 B
TypeScript
/* @vitest-environment jsdom */
|
|
|
|
import { render, screen } from '@testing-library/react';
|
|
import userEvent from '@testing-library/user-event';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
|
|
import { BarkBattleResultPanel } from '../BarkBattleResultPanel';
|
|
|
|
describe('BarkBattleResultPanel', () => {
|
|
it('展示胜负、叫声次数并支持再来一局', async () => {
|
|
const onRestart = vi.fn();
|
|
render(
|
|
<BarkBattleResultPanel
|
|
result={{ winner: 'player', playerBarkCount: 6, opponentBarkCount: 2, finalEnergy: 72, score: 792 }}
|
|
onRestart={onRestart}
|
|
/>,
|
|
);
|
|
|
|
expect(screen.getByRole('dialog', { name: '对战结算' })).toBeTruthy();
|
|
expect(screen.getByText('汪力压制成功')).toBeTruthy();
|
|
expect(screen.getByText('6')).toBeTruthy();
|
|
|
|
await userEvent.click(screen.getByRole('button', { name: '再来一局' }));
|
|
expect(onRestart).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|