diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/commands.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/commands.test.ts index f9f971bdbda..4dbeb0519e2 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/commands.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/commands.test.ts @@ -13,33 +13,26 @@ suite('vscode API - commands', () => { teardown(assertNoRpc); - test('getCommands', function (done) { + test('getCommands', async function () { - let p1 = commands.getCommands().then(commands => { - let hasOneWithUnderscore = false; - for (let command of commands) { - if (command[0] === '_') { - hasOneWithUnderscore = true; - break; - } + let cmds = await commands.getCommands(); + let hasOneWithUnderscore = false; + for (let command of cmds) { + if (command[0] === '_') { + hasOneWithUnderscore = true; + break; } - assert.ok(hasOneWithUnderscore); - }, done); + } + assert.ok(hasOneWithUnderscore); - let p2 = commands.getCommands(true).then(commands => { - let hasOneWithUnderscore = false; - for (let command of commands) { - if (command[0] === '_') { - hasOneWithUnderscore = true; - break; - } + cmds = await commands.getCommands(true); + for (let command of cmds) { + if (command[0] === '_') { + hasOneWithUnderscore = true; + break; } - assert.ok(!hasOneWithUnderscore); - }, done); - - Promise.all([p1, p2]).then(() => { - done(); - }, done); + } + assert.ok(!hasOneWithUnderscore); }); test('command with args', async function () { diff --git a/src/vs/base/test/common/async.test.ts b/src/vs/base/test/common/async.test.ts index e55ea2f617b..08ff52dfccd 100644 --- a/src/vs/base/test/common/async.test.ts +++ b/src/vs/base/test/common/async.test.ts @@ -8,6 +8,7 @@ import * as async from 'vs/base/common/async'; import { isPromiseCanceledError } from 'vs/base/common/errors'; import { URI } from 'vs/base/common/uri'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; +import { Event } from 'vs/base/common/event'; suite('Async', () => { @@ -484,13 +485,11 @@ suite('Async', () => { }); }); - test('Queue - events', function (done) { + test('Queue - events', function () { let queue = new async.Queue(); let finished = false; - queue.onFinished(() => { - done(); - }); + const onFinished = Event.toPromise(queue.onFinished); let res: number[] = []; @@ -508,6 +507,8 @@ suite('Async', () => { assert.ok(!finished); }); }); + + return onFinished; }); test('ResourceQueue - simple', function () { diff --git a/src/vs/base/test/common/cancellation.test.ts b/src/vs/base/test/common/cancellation.test.ts index 8f3c82c36ab..d1c55d1ab5a 100644 --- a/src/vs/base/test/common/cancellation.test.ts +++ b/src/vs/base/test/common/cancellation.test.ts @@ -12,7 +12,7 @@ suite('CancellationToken', function () { assert.strictEqual(typeof CancellationToken.None.onCancellationRequested, 'function'); }); - test('cancel before token', function (done) { + test('cancel before token', function () { const source = new CancellationTokenSource(); assert.strictEqual(source.token.isCancellationRequested, false); @@ -20,9 +20,8 @@ suite('CancellationToken', function () { assert.strictEqual(source.token.isCancellationRequested, true); - source.token.onCancellationRequested(function () { - assert.ok(true); - done(); + return new Promise(resolve => { + source.token.onCancellationRequested(() => resolve()); }); });