refactor: make game host return the setup promise

This commit is contained in:
2026-04-04 23:58:12 +08:00
parent dd73deabb0
commit cc7f302677
2 changed files with 16 additions and 12 deletions
+5 -5
View File
@@ -150,7 +150,7 @@ describe('GameHost', () => {
const newPromptPromise = waitForPromptEvent(host);
// Reset - should reset state and start new game
await host.setup('setup');
host.setup('setup');
// State should be back to initial
expect(host.context._state.value.currentPlayer).toBe('X');
@@ -173,7 +173,7 @@ describe('GameHost', () => {
await promptPromise;
// Setup should cancel the active prompt and reset state
await host.setup('setup');
host.setup('setup');
// The original runPromise should be rejected due to cancellation
try {
@@ -188,11 +188,11 @@ describe('GameHost', () => {
expect(host.context._state.value.turn).toBe(0);
});
it('should throw error when disposed', async () => {
it('should throw error when disposed', () => {
const { host } = createTestHost();
host.dispose();
await expect(host.setup('setup')).rejects.toThrow('GameHost is disposed');
expect(() => host.setup('setup')).toThrow('GameHost is disposed');
});
});
@@ -245,7 +245,7 @@ describe('GameHost', () => {
const promptPromise = waitForPromptEvent(host);
// Initial setup via reset
await host.setup('setup');
host.setup('setup');
expect(setupCount).toBe(1);
// State should be running