Skip to content

Commit

Permalink
Write a complete end to end test. (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix authored Dec 14, 2023
1 parent 9a625c8 commit e20fbe3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
submodules: 'true'

- uses: actions/setup-node@v4
with:
cache: 'npm'

- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true

- name: Install dependencies
timeout-minutes: 10
run: npm ci
Expand Down
5 changes: 4 additions & 1 deletion .vscode-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const {defineConfig} = require('@vscode/test-cli');

module.exports = defineConfig({files: 'out/test/**/*.test.js'});
module.exports = defineConfig({
files: 'out/test/**/*.test.js',
workspaceFolder: './sus'
});
3 changes: 3 additions & 0 deletions gems.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gem "sus"
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;
}
24 changes: 20 additions & 4 deletions src/test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,25 @@ import * as assert from 'assert';
import * as vscode from 'vscode';
//import * as myExtension from '../extension';

suite('Extension Test Suite', () => {
test('Sample test', () => {
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
test('lists tests', async () => {
// Find the "Testing" activity bar icon and click it:
await vscode.commands.executeCommand('workbench.view.extension.test');

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

assert(identifiers.length > 0);

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

assert(project);
assert(project.controller);

await project.controller.loadTree();

assert(project.controller.items.size > 0);
});
});

0 comments on commit e20fbe3

Please sign in to comment.