refactor: change PromptEvent reject/resolve to cancel/tryCommit
This commit is contained in:
@@ -464,7 +464,7 @@ describe('Boop - game flow', () => {
|
||||
expect(promptEvent).not.toBeNull();
|
||||
expect(promptEvent.schema.name).toBe('play');
|
||||
|
||||
promptEvent.reject(new Error('test end'));
|
||||
promptEvent.cancel('test end');
|
||||
|
||||
const result = await runPromise;
|
||||
expect(result.success).toBe(false);
|
||||
@@ -480,7 +480,8 @@ describe('Boop - game flow', () => {
|
||||
expect(promptEvent).not.toBeNull();
|
||||
expect(promptEvent.schema.name).toBe('play');
|
||||
|
||||
promptEvent.resolve({ name: 'play', params: ['white', 2, 2], options: {}, flags: {} });
|
||||
const error = promptEvent.tryCommit({ name: 'play', params: ['white', 2, 2], options: {}, flags: {} });
|
||||
expect(error).toBeNull();
|
||||
|
||||
const result = await runPromise;
|
||||
expect(result.success).toBe(true);
|
||||
@@ -497,12 +498,14 @@ describe('Boop - game flow', () => {
|
||||
const runPromise = ctx.commands.run<{winner: WinnerType}>('turn white');
|
||||
|
||||
const promptEvent1 = await promptPromise;
|
||||
promptEvent1.resolve({ name: 'play', params: ['black', 2, 2], options: {}, flags: {} });
|
||||
const error1 = promptEvent1.tryCommit({ name: 'play', params: ['black', 2, 2], options: {}, flags: {} });
|
||||
expect(error1).not.toBeNull();
|
||||
|
||||
const promptEvent2 = await waitForPrompt(ctx);
|
||||
expect(promptEvent2).not.toBeNull();
|
||||
|
||||
promptEvent2.resolve({ name: 'play', params: ['white', 2, 2], options: {}, flags: {} });
|
||||
const error2 = promptEvent2.tryCommit({ name: 'play', params: ['white', 2, 2], options: {}, flags: {} });
|
||||
expect(error2).toBeNull();
|
||||
|
||||
const result = await runPromise;
|
||||
expect(result.success).toBe(true);
|
||||
@@ -519,12 +522,14 @@ describe('Boop - game flow', () => {
|
||||
const runPromise = ctx.commands.run<{winner: WinnerType}>('turn white');
|
||||
|
||||
const promptEvent1 = await promptPromise;
|
||||
promptEvent1.resolve({ name: 'play', params: ['white', 2, 2], options: {}, flags: {} });
|
||||
const error1 = promptEvent1.tryCommit({ name: 'play', params: ['white', 2, 2], options: {}, flags: {} });
|
||||
expect(error1).not.toBeNull();
|
||||
|
||||
const promptEvent2 = await waitForPrompt(ctx);
|
||||
expect(promptEvent2).not.toBeNull();
|
||||
|
||||
promptEvent2.resolve({ name: 'play', params: ['white', 0, 0], options: {}, flags: {} });
|
||||
const error2 = promptEvent2.tryCommit({ name: 'play', params: ['white', 0, 0], options: {}, flags: {} });
|
||||
expect(error2).toBeNull();
|
||||
|
||||
const result = await runPromise;
|
||||
expect(result.success).toBe(true);
|
||||
@@ -543,12 +548,13 @@ describe('Boop - game flow', () => {
|
||||
const runPromise = ctx.commands.run<{winner: WinnerType}>('turn white');
|
||||
|
||||
const promptEvent1 = await promptPromise;
|
||||
promptEvent1.resolve({ name: 'play', params: ['white', 0, 0], options: {}, flags: {} });
|
||||
const error1 = promptEvent1.tryCommit({ name: 'play', params: ['white', 0, 0], options: {}, flags: {} });
|
||||
expect(error1).not.toBeNull();
|
||||
|
||||
const promptEvent2 = await waitForPrompt(ctx);
|
||||
expect(promptEvent2).not.toBeNull();
|
||||
|
||||
promptEvent2.reject(new Error('test end'));
|
||||
promptEvent2.cancel('test end');
|
||||
|
||||
const result = await runPromise;
|
||||
expect(result.success).toBe(false);
|
||||
|
||||
Reference in New Issue
Block a user