Skip to content

Commit ec1ca94

Browse files
committed
update to using existing helper fn for waiting and timeout
1 parent 8ea3827 commit ec1ca94

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

packages/core/src/test/shared/ui/sam/ecrPrompter.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import * as SamUtilsModule from '../../../../shared/sam/utils'
1212
import * as ButtonsModule from '../../../../shared/ui/buttons'
1313
import { createEcrPrompter } from '../../../../shared/ui/sam/ecrPrompter'
1414
import { intoCollection } from '../../../../shared/utilities/collectionUtils'
15+
import { sleep } from '../../../../shared/utilities/timeoutUtils'
1516

1617
describe('createEcrPrompter', () => {
1718
let sandbox: sinon.SinonSandbox
@@ -76,7 +77,7 @@ describe('createEcrPrompter', () => {
7677

7778
// Act
7879
const prompter = createEcrPrompter(ecrClient, mementoRootKey)
79-
await new Promise((f) => setTimeout(f, 50))
80+
await sleep(50)
8081

8182
// Assert
8283
assert.ok(createCommonButtonsStub.calledOnce)
@@ -103,7 +104,7 @@ describe('createEcrPrompter', () => {
103104

104105
// Act
105106
const prompter = createEcrPrompter(ecrClient, mementoRootKey)
106-
await new Promise((f) => setTimeout(f, 50))
107+
await sleep(50)
107108

108109
// Assert
109110
assert.ok(createCommonButtonsStub.calledOnce)

packages/core/src/test/shared/ui/sam/stackPrompter.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { DefaultCloudFormationClient } from '../../../../shared/clients/cloudFor
1414
import { samSyncUrl } from '../../../../shared/constants'
1515
import { createStackPrompter } from '../../../../shared/ui/sam/stackPrompter'
1616
import { intoCollection } from '../../../../shared/utilities/collectionUtils'
17+
import { sleep } from '../../../../shared/utilities/timeoutUtils'
1718

1819
describe('createStackPrompter', () => {
1920
let sandbox: sinon.SinonSandbox
@@ -81,7 +82,7 @@ describe('createStackPrompter', () => {
8182

8283
// Act
8384
const prompter = createStackPrompter(cfnClient, mementoRootKey, samSyncUrl)
84-
await new Promise((f) => setTimeout(f, 50))
85+
await sleep(50)
8586

8687
// Assert
8788
assert.ok(createCommonButtonsStub.calledOnce)
@@ -108,7 +109,7 @@ describe('createStackPrompter', () => {
108109

109110
// Act
110111
const prompter = createStackPrompter(cfnClient, mementoRootKey, samSyncUrl)
111-
await new Promise((f) => setTimeout(f, 50))
112+
await sleep(50)
112113

113114
// Assert
114115
assert.ok(createCommonButtonsStub.calledOnce)

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import assert from 'assert'
77
import { TestInputBox, TestQuickPick } from '../vscode/quickInput'
88
import { getTestWindow, TestWindow } from '../vscode/window'
9+
import { waitUntil } from '../../../shared/utilities/timeoutUtils'
910

1011
interface PrompterTesterConfig {
1112
testWindow?: TestWindow
@@ -111,13 +112,7 @@ export class PrompterTester {
111112
}
112113

113114
try {
114-
const timeoutPromise = new Promise<never>((_, reject) => {
115-
setTimeout(() => {
116-
reject(new Error(`Handler for "${input.title}" exceeded ${this.handlerTimout}ms timeout`))
117-
}, this.handlerTimout)
118-
})
119-
120-
await Promise.race([handler(input), timeoutPromise])
115+
await waitUntil(handler(input), { timeout: this.handlerTimout, interval: 50 })
121116
} catch (e) {
122117
// clean up UI on callback function early exit (e.g assertion failure)
123118
await input.dispose()

0 commit comments

Comments
 (0)