import { Rhum } from "./dev_deps.ts";import { act, runCommand } from "./act.ts";import { settings } from "./settings.ts";
Rhum.testPlan("act.test.ts", () => { const encoder = new TextEncoder();
Rhum.testSuite("runCommand()", () => { Rhum.testCase( "should return true when a command's exit code is 0", async () => { const cmd = Deno.run({ cmd: ["git", "init"], });
Rhum.asserts.assertEquals(await runCommand(cmd), true); }, );
Rhum.testCase( "should return false when a command's exit code is greater than 0", async () => { const cmd = Deno.run({ cmd: ["git", "checkout", "foo"], });
Rhum.asserts.assertEquals(await runCommand(cmd), false); }, ); });
Rhum.testSuite("act()", () => { Rhum.beforeEach(async () => { await Deno.mkdir("./templates/test_directory_act", { recursive: true}); });
Rhum.afterEach(async () => { await Deno.remove("./templates/test_directory_act", { recursive: true }); await Deno.remove("./test_directory_act", {recursive: true }); });
Rhum.testCase( "should make a project from a template when template is passed", async () => { settings.path = "test_directory_act"; settings.template = "deno_basic"; settings.git = false;
await act();
Rhum.asserts.assert(async () => { await Deno.writeFile( "templates/test_directory_act/mod.ts", encoder.encode("export {};"), { create: false }, ); }); }, );
Rhum.testCase( "should make a project from a template when template is passed II", async () => { settings.path = "test_directory_act"; settings.template = ""; settings.git = true;
await act();
Rhum.asserts.assert(async () => { await Deno.writeFile( "templates/test_directory_act/mod.ts", encoder.encode("export {};"), { create: false }, ); }); }, );
Rhum.testCase( "should run deno cache if settings.cache is true", async () => { settings.cache = true; settings.path = "test_directory_act"; settings.template = "deno_basic"; settings.git = false;
await act();
}, );
Rhum.testCase( "should create import_map.json if setting.map is true", async () => { settings.map = true; settings.cache = false; settings.path = "test_directory_act"; settings.template = ""; settings.git = false;
await act();
}, ); });});
Rhum.run();