Skip to content

Commit

Permalink
Really fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed May 10, 2020
1 parent 36f33b5 commit 1e2c4d7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
}
],
"engines": {
"vscode": "1.45.0"
"vscode": "^1.44.0"
},
"activationEvents": [
"onDebugInitialConfigurations",
Expand Down Expand Up @@ -3241,4 +3241,4 @@
]
}
}
}
}
8 changes: 6 additions & 2 deletions test/integrationTests/launchConfiguration.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ suite(`Tasks generation: ${testAssetWorkspace.description}`, function () {

test("Starting .NET Core Launch (console) from the workspace root should create an Active Debug Session", async () => {

vscode.debug.onDidChangeActiveDebugSession((e) => {
const onChangeSubscription = vscode.debug.onDidChangeActiveDebugSession((e) => {
onChangeSubscription.dispose();
expect(vscode.debug.activeDebugSession).not.to.be.undefined;
expect(vscode.debug.activeDebugSession.type).to.equal("coreclr");
});
Expand All @@ -47,7 +48,10 @@ suite(`Tasks generation: ${testAssetWorkspace.description}`, function () {
expect(result, "Debugger could not be started.");

let debugSessionTerminated = new Promise(resolve => {
vscode.debug.onDidTerminateDebugSession((e) => resolve());
const onTerminateSubscription = vscode.debug.onDidTerminateDebugSession((e) => {
onTerminateSubscription.dispose();
resolve();
});
});

await debugSessionTerminated;
Expand Down
4 changes: 2 additions & 2 deletions test/integrationTests/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function assertWithPoll<T>(
}

function defaultPollExpression<T>(value: T): boolean {
return value !== undefined && ((Array.isArray(value) && value.length > 0) || !Array.isArray(value));
return value !== undefined && ((Array.isArray(value) && value.length > 0) || (!Array.isArray(value) && !!value));
}

export async function pollDoesNotHappen<T>(
Expand All @@ -68,7 +68,7 @@ export async function pollDoesNotHappen<T>(
}

export async function poll<T>(
getValue: () => T,
getValue: () => Promise<T> | T,
duration: number,
step: number,
expression: (input: T) => boolean = defaultPollExpression): Promise<T> {
Expand Down
2 changes: 1 addition & 1 deletion test/integrationTests/semanticTokensProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ suite(`SemanticTokensProvider: ${testAssetWorkspace.description}`, function () {
}
});

await poll(() => { }, 25000, 500, _ => isWorkspaceLoaded);
await poll(() => isWorkspaceLoaded, 25000, 500);

const fileName = 'semanticTokens.cs';
const projectDirectory = testAssetWorkspace.projects[0].projectDirectoryPath;
Expand Down
24 changes: 10 additions & 14 deletions test/integrationTests/virtualDocumentTracker.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as vscode from 'vscode';

import { should, expect } from 'chai';
import { should, assert } from 'chai';
import { activateCSharpExtension } from './integrationHelpers';
import testAssetWorkspace from './testAssets/testAssetWorkspace';
import { IDisposable } from '../../src/Disposable';
Expand All @@ -15,16 +15,19 @@ chai.use(require('chai-arrays'));
chai.use(require('chai-fs'));

suite(`Virtual Document Tracking ${testAssetWorkspace.description}`, function () {
let virtualScheme: string = "virtual";
const virtualScheme = "virtual";
let virtualDocumentRegistration: IDisposable;
let virtualUri: vscode.Uri;

suiteSetup(async function () {
should();
await activateCSharpExtension();
await testAssetWorkspace.restore();

let virtualCSharpDocumentProvider = new VirtualCSharpDocumentProvider();
const virtualCSharpDocumentProvider = new VirtualCSharpDocumentProvider();
virtualDocumentRegistration = vscode.workspace.registerTextDocumentContentProvider(virtualScheme, virtualCSharpDocumentProvider);
virtualUri = vscode.Uri.parse(`${virtualScheme}://${testAssetWorkspace.projects[0].projectDirectoryPath}/_virtualFile.cs`);

await activateCSharpExtension();
await testAssetWorkspace.restore();
});

suiteTeardown(async () => {
Expand All @@ -33,19 +36,12 @@ suite(`Virtual Document Tracking ${testAssetWorkspace.description}`, function ()
});

test("Virtual documents are operated on.", async () => {
let virtualUri = vscode.Uri.parse(`${virtualScheme}://${testAssetWorkspace.projects[0].projectDirectoryPath}/_virtualFile.cs`);
await vscode.workspace.openTextDocument(virtualUri);

let position = new vscode.Position(2, 4);
let position = new vscode.Position(2, 0);
let completionItems = <vscode.CompletionList>await vscode.commands.executeCommand("vscode.executeCompletionItemProvider", virtualUri, position);

expect(completionItems.items).to.satisfy(() => {
let item = completionItems.items.find(item => {
return item.label === "while";
});

return item;
});
assert.include(completionItems.items.map(({ label }) => label), "while");
});
});

Expand Down

0 comments on commit 1e2c4d7

Please sign in to comment.