feat: add bark battle browser prototype
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/* @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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user