Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions editors/vscode/.vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { defineConfig } from '@vscode/test-cli';
import { existsSync, mkdirSync } from 'node:fs';

if (!existsSync('./test_workspace')) {
mkdirSync('./test_workspace');
}

export default defineConfig({
files: 'out/**/*.spec.js',
Expand Down
66 changes: 33 additions & 33 deletions editors/vscode/client/extension.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { deepStrictEqual, notEqual, strictEqual } from 'assert';
import { commands, extensions, window, workspace } from 'vscode';
import { readFile } from 'fs/promises';
import { commands, extensions, Uri, window, workspace, WorkspaceEdit } from 'vscode';

// const WORKSPACE_DIR = workspace.workspaceFolders![0].uri.toString();
// const filePath = WORKSPACE_DIR + '/debugger.js';
// const fileUri = Uri.parse(filePath);
const WORKSPACE_DIR = workspace.workspaceFolders![0].uri.toString();
const filePath = WORKSPACE_DIR + '/debugger.js';
const fileUri = Uri.parse(filePath);

const sleep = (time: number) => new Promise((r) => setTimeout(r, time));

Expand All @@ -13,11 +14,11 @@ suite('commands', () => {
await ext.activate();
});

// suiteTeardown(async () => {
// const edit = new WorkspaceEdit();
// edit.deleteFile(fileUri);
// await workspace.applyEdit(edit);
// });
suiteTeardown(async () => {
const edit = new WorkspaceEdit();
edit.deleteFile(fileUri);
await workspace.applyEdit(edit);
});

test('listed commands', async () => {
const oxcCommands = (await commands.getCommands(true)).filter(x => x.startsWith('oxc.'));
Expand Down Expand Up @@ -49,30 +50,29 @@ suite('commands', () => {

const isEnabledAfter = workspace.getConfiguration('oxc').get<boolean>('enable');
strictEqual(isEnabledAfter, false);

// enable it for other tests
await commands.executeCommand('oxc.toggleEnable');
await sleep(500);
});

// ToDo: check why this is not working,
// even with .gitignore deleted in th test_workspace
//
// test('oxc.fixAll', async () => {
// const edit = new WorkspaceEdit();
// edit.createFile(fileUri, {
// contents: Buffer.from('/* 😊 */debugger;'),
// });
//
// await workspace.applyEdit(edit);
// await window.showTextDocument(fileUri);
// await sleep(500);
// await commands.executeCommand('oxc.fixAll', {
// uri: fileUri.toString(),
// });
// await workspace.saveAll();
// await sleep(1000);
//
// const content = await readFile(fileUri.fsPath, {
// encoding: 'utf8',
// });
//
// strictEqual(content, '/* 😊 */');
// });
test('oxc.fixAll', async () => {
const edit = new WorkspaceEdit();
edit.createFile(fileUri, {
contents: Buffer.from('/* 😊 */debugger;'),
});

await workspace.applyEdit(edit);
await window.showTextDocument(fileUri);
await commands.executeCommand('oxc.fixAll', {
uri: fileUri.toString(),
});
await workspace.saveAll();

const content = await readFile(fileUri.fsPath, {
encoding: 'utf8',
});

strictEqual(content, '/* 😊 */');
});
});
2 changes: 0 additions & 2 deletions editors/vscode/test_workspace/.gitignore

This file was deleted.