diff --git a/.vscode-test.js b/.vscode-test.js index a18064b..544c61f 100644 --- a/.vscode-test.js +++ b/.vscode-test.js @@ -10,5 +10,5 @@ module.exports = defineConfig([ ui: "tdd", timeout: 20000, }, - } + }, ]); diff --git a/src/commands/addCommand.ts b/src/commands/addCommand.ts index 80e89f6..038edf3 100644 --- a/src/commands/addCommand.ts +++ b/src/commands/addCommand.ts @@ -172,7 +172,7 @@ async function askDisabledByDefault(cmd: Command): Promise { } } -function makeCommandFilename(name: string | undefined) { +export function makeCommandFilename(name: string | undefined) { if (!name) { return name; } diff --git a/src/test/suite/addCommand.test.ts b/src/test/suite/addCommand.test.ts index cc71ae3..e6578db 100644 --- a/src/test/suite/addCommand.test.ts +++ b/src/test/suite/addCommand.test.ts @@ -1,25 +1,52 @@ import * as assert from "assert"; -import { makeCommandFunctionName } from "../../commands/addCommand"; +import { makeCommandFilename, makeCommandFunctionName } from "../../commands/addCommand"; suite("addCommand", () => { test("makeCommandFunctionName", () => { [ { - in: "test", + input: "test", should: "Test", }, { - in: "Test", + input: "Test", should: "Test", }, { - in: "A Cmd - With Characters", - should: "ACmdWithCharacters" + input: "A Cmd - With Characters", + should: "ACmdWithCharacters", }, { - in: "A ~. Cmd", - should: "ACmd" - } - ].forEach((e) => assert.strictEqual(makeCommandFunctionName(e.in), e.should)); + input: "A ~. Cmd", + should: "ACmd", + }, + ].forEach(({ input, should }) => assert.strictEqual(makeCommandFunctionName(input), should)); + + [ + { + input: "test", + not: "test", + }, + ].forEach(({ input, not }) => assert.notStrictEqual(makeCommandFunctionName(input), not)); + }); + test("makeCommandFilename", () => { + [ + { + input: "Test A Command", + should: "testACommand", + }, + { + input: "Test ~ A Command", + should: "test~ACommand", + }, + { + input: "Test - A - Command", + should: "test-A-Command", + }, + { + input: "Test . A - Command", + should: "test.A-Command", + }, + ].forEach(({ input, should }) => assert.strictEqual(makeCommandFilename(input), should)); }); }); diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts deleted file mode 100644 index 2f671d3..0000000 --- a/src/test/suite/extension.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as assert from "assert"; - -// You can import and use all API from the 'vscode' module -// as well as import your extension to test it -import * as vscode from "vscode"; -// import * as myExtension from '../../extension'; - -suite("Extension Test Suite", () => { - vscode.window.showInformationMessage("Start all tests."); - - test("Sample test", () => { - assert.strictEqual(-1, [1, 2, 3].indexOf(5)); - assert.strictEqual(-1, [1, 2, 3].indexOf(0)); - }); -});