mirror of
https://github.com/coder/code-server.git
synced 2026-05-05 12:05:18 +02:00
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { join } from 'vs/base/common/path';
|
|
import { URI } from 'vs/base/common/uri';
|
|
import { isWindows } from 'vs/base/common/platform';
|
|
|
|
export type ValueCallback<T = any> = (value: T | Promise<T>) => void;
|
|
|
|
export function toResource(this: any, path: string) {
|
|
if (isWindows) {
|
|
return URI.file(join('C:\\', btoa(this.test.fullTitle()), path));
|
|
}
|
|
|
|
return URI.file(join('/', btoa(this.test.fullTitle()), path));
|
|
}
|
|
|
|
export function suiteRepeat(n: number, description: string, callback: (this: any) => void): void {
|
|
for (let i = 0; i < n; i++) {
|
|
suite(`${description} (iteration ${i})`, callback);
|
|
}
|
|
}
|
|
|
|
export function testRepeat(n: number, description: string, callback: (this: any) => any): void {
|
|
for (let i = 0; i < n; i++) {
|
|
test(`${description} (iteration ${i})`, callback);
|
|
}
|
|
}
|
|
|
|
export async function assertThrowsAsync(block: () => any, message: string | Error = 'Missing expected exception'): Promise<void> {
|
|
try {
|
|
await block();
|
|
} catch {
|
|
return;
|
|
}
|
|
|
|
const err = message instanceof Error ? message : new Error(message);
|
|
throw err;
|
|
}
|