Skip to content

Commit

Permalink
Add working test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Dec 13, 2023
1 parent 9f1ac92 commit 5c1ae26
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import * as vscode from 'vscode';
import {Project} from './sus';

export async function activate(context: vscode.ExtensionContext) {
export type Projects = {[key: string]: Project};

export async function activate(context: vscode.ExtensionContext): Promise<Projects> {
const projects = {} as {[key: string]: Project};

async function addProject(workspaceFolder: vscode.WorkspaceFolder) {
Expand Down Expand Up @@ -40,9 +42,11 @@ export async function activate(context: vscode.ExtensionContext) {
return null;
}

vscode.workspace.onDidChangeWorkspaceFolders(updateProjects);
context.subscriptions.push(vscode.workspace.onDidChangeWorkspaceFolders(updateProjects));

if (vscode.workspace.workspaceFolders) {
vscode.workspace.workspaceFolders.forEach(addProject);
}

return projects;
}
25 changes: 19 additions & 6 deletions src/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@ import * as assert from 'assert';
import * as vscode from 'vscode';
//import * as myExtension from '../extension';

suite('Test Extension', () => {
test('Tests are listed', () => {
// Find the "Testing" activity bar icon and click it:
vscode.commands.executeCommand('workbench.view.extension.test');
test('lists tests', async () => {
// Find the "Testing" activity bar icon and click it:
await vscode.commands.executeCommand('workbench.view.extension.test');

// Find the "Run All Tests" button and click it:
// await vscode.commands.executeCommand('testing.runAll');

const extension = vscode.extensions.getExtension('socketry.sus-vscode');
const projects = extension?.exports;
const identifiers = Object.keys(projects);

assert(identifiers.length > 0);

identifiers.forEach((key) => {
const project = projects[key];
const workspace = project.workspaceFolder;

// Find the "Run All Tests" button and click it:
vscode.commands.executeCommand('workbench.testing.action.runAllTests');
assert(project);
assert(project.controller);
assert(project.controller.items.size > 0);
});
});

0 comments on commit 5c1ae26

Please sign in to comment.