integration tests - use async test (#120225)
This commit is contained in:
parent
6f8b983dfd
commit
8de3791477
3 changed files with 24 additions and 31 deletions
|
@ -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 () {
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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<void>(resolve => {
|
||||
source.token.onCancellationRequested(() => resolve());
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue