diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts index b5910de..a5abb9c 100644 --- a/src/test/suite/extension.test.ts +++ b/src/test/suite/extension.test.ts @@ -9,11 +9,12 @@ import * as myExtension from "../../extension.js"; import * as uninstall from "../../commands/uninstall.js"; import * as sinon from "sinon"; +// TODO: should extract the tests to the directory of the file under test suite("Extension Test Suite", () => { vscode.window.showInformationMessage("Start all tests."); let showInformationMessage; - setup(function () { + setup(function() { fs.rmSync("./test-bin", { recursive: true, force: true }); showInformationMessage = sinon .stub(vscode.window, "showInformationMessage") @@ -24,18 +25,19 @@ suite("Extension Test Suite", () => { ); }); - teardown(function () { + teardown(function() { sinon.restore(); }); - test("downloads Next LS", async function () { + // TODO: should probably mock out the api calls to github + test("downloads Next LS", async function() { fs.mkdirSync("./test-bin", { recursive: true }); let result = await myExtension.ensureNextLSDownloaded("test-bin"); assert.equal(path.normalize(result), path.normalize("test-bin/nextls")); }); - test("uninstalls Next LS", async function () { + test("uninstalls Next LS", async function() { fs.mkdirSync("./test-bin", { recursive: true }); fs.writeFileSync("./test-bin/nextls", "hello word"); @@ -46,4 +48,14 @@ suite("Extension Test Suite", () => { `Uninstalled Next LS from ${path.normalize("test-bin/nextls")}` ); }); + + test("fails to uninstalls Next LS", async function() { + let showErrorMessage = sinon.stub(vscode.window, "showErrorMessage"); + await uninstall.run("./test-bin"); + + assert.equal( + showErrorMessage.getCall(0).args[0], + `Failed to uninstall Next LS from ${path.normalize("test-bin/nextls")} due to Error: ENOENT: no such file or directory, lstat 'test-bin/nextls'` + ); + }); });