some 💄, some API todos

This commit is contained in:
Johannes Rieken
2021-02-12 17:54:26 +01:00
parent c83064b982
commit 52f633d19c
4 changed files with 24 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ vscode.workspace.registerFileSystemProvider(testFs.scheme, testFs, { isCaseSensi
export async function createRandomFile(contents = '', dir: vscode.Uri | undefined = undefined, ext = ''): Promise<vscode.Uri> {
let fakeFile: vscode.Uri;
if (dir) {
assert.equal(dir.scheme, testFs.scheme);
assert.strictEqual(dir.scheme, testFs.scheme);
fakeFile = dir.with({ path: dir.path + '/' + rndName() + ext });
} else {
fakeFile = vscode.Uri.parse(`${testFs.scheme}:/${rndName() + ext}`);
@@ -117,3 +117,19 @@ export function assertNoRpcFromEntry(entry: [obj: any, name: string]) {
assert.strictEqual(rpcPaths.length, 0, rpcPaths.join('\n'));
assert.strictEqual(proxyPaths.length, 0, proxyPaths.join('\n')); // happens...
}
export async function asPromise<T>(event: vscode.Event<T>, timeout = 1000): Promise<T> {
return new Promise<T>((resolve, reject) => {
const handle = setTimeout(() => {
sub.dispose();
reject(new Error('asPromise TIMEOUT reached'));
}, timeout);
const sub = event(e => {
clearTimeout(handle);
sub.dispose();
resolve(e);
});
});
}