Skip to content

Commit

Permalink
Add uninstall test when dim-lock.json does not exsist
Browse files Browse the repository at this point in the history
  • Loading branch information
ryo-ma committed Oct 18, 2022
1 parent e2df916 commit ff1171e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/libs/actions.uninstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ import { fileExists, removeTemporaryFiles, temporaryDirectory } from "../helper.

describe("UninstallAction", () => {
let consoleLogStub: Stub;
let denoExitStub: Stub;
let originalDirectory: string;

beforeEach(() => {
consoleLogStub = stub(console, "log");
denoExitStub = stub(Deno, "exit");
originalDirectory = Deno.cwd();
Deno.chdir(temporaryDirectory);
});

afterEach(() => {
removeTemporaryFiles();
consoleLogStub.restore();
denoExitStub.restore();
Deno.chdir(originalDirectory);
});

Expand Down Expand Up @@ -80,6 +83,33 @@ describe("UninstallAction", () => {
contents: [],
});
});
it("runs with a name when dim-lock.json does not exsist", async () => {
const dimData: DimJSON = {
fileVersion: "1.1",
contents: [
{
name: "test1",
url: "https://example.com/dummy.test",
catalogUrl: null,
catalogResourceId: null,
postProcesses: [],
headers: {},
},
],
};
await Deno.writeTextFile(
DEFAULT_DIM_FILE_PATH,
JSON.stringify(dimData, null, 2),
);
await new UninstallAction().execute(undefined as void, "test1");
assertSpyCall(consoleLogStub, 0, {
args: [Colors.green("Removed a content from the dim.json.")],
});
assertSpyCall(consoleLogStub, 1, {
args: ["Not found a dim-lock.json"],
});
assertSpyCall(denoExitStub, 0, { args: [1] });
});

it("runs with a name not recorded in dim.json or dim-lock.json and displays an error message.", async () => {
const dimData: DimJSON = {
Expand Down

0 comments on commit ff1171e

Please sign in to comment.