Skip to content

Commit 1e986ad

Browse files
committed
update PrompterTester following merge from master
1 parent 5fc848e commit 1e986ad

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

packages/core/src/test/shared/wizards/prompterTester.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ export class PrompterTester {
1818
private inputBoxHanlder: Map<string, (input: TestInputBox) => void> = new Map()
1919
private testWindow: TestWindow
2020
private callLog = Array<string>()
21-
private handlerTimout: number = 3000 // Default timeout to 3 seconds
21+
private handlerTimeout: number = 3000 // Default timeout to 3 seconds
2222
private callLogCount = new Map<string, number>()
2323

2424
private constructor(config?: PrompterTesterConfig) {
2525
this.testWindow = config?.testWindow || getTestWindow()
26-
this.handlerTimout = config?.handlerTimeout || this.handlerTimout
26+
this.handlerTimeout = config?.handlerTimeout || this.handlerTimeout
2727
}
2828

2929
static init(config?: PrompterTesterConfig): PrompterTester {
3030
return new PrompterTester(config)
3131
}
3232

33-
handleQuickPick(titlePattern: string, handler: (input: TestQuickPick) => void): PrompterTester {
33+
handleQuickPick(titlePattern: string, handler: (input: TestQuickPick) => void | Promise<void>): PrompterTester {
3434
this.quickPickHandlers.set(titlePattern, handler)
3535
this.callLogCount.set(titlePattern, 0)
3636
return this
3737
}
3838

39-
handleInputBox(titlePattern: string, handler: (input: TestInputBox) => void): PrompterTester {
39+
handleInputBox(titlePattern: string, handler: (input: TestInputBox) => void | Promise<void>): PrompterTester {
4040
this.inputBoxHanlder.set(titlePattern, handler)
4141
this.callLogCount.set(titlePattern, 0)
4242
return this
@@ -112,7 +112,13 @@ export class PrompterTester {
112112
}
113113

114114
try {
115-
await waitUntil(handler(input), { timeout: this.handlerTimout, interval: 50 })
115+
await waitUntil(
116+
async () => {
117+
await handler(input)
118+
return true
119+
},
120+
{ timeout: this.handlerTimeout, interval: 50, truthy: false }
121+
)
116122
} catch (e) {
117123
// clean up UI on callback function early exit (e.g assertion failure)
118124
await input.dispose()

0 commit comments

Comments
 (0)