Skip to content

Commit

Permalink
other: Fixed error in test new.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna-Klatzer committed Jun 25, 2024
1 parent 850c079 commit 80fcb57
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions test/module/cli/new.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import { assert } from "chai";
import * as path from "path";
import * as fsSync from "fs";
import * as fs from "fs/promises";
import { test } from "@oclif/test";
import { version } from "@kipper/core";

const originalCwd = process.cwd();
const tempFolder = path.join(__dirname, "..", "..", "temp");

function createTemp(): void {
if (!fsSync.existsSync(tempFolder)) {
fsSync.mkdirSync(tempFolder, { recursive: true });
}
}

function removeTemp(): void {
if (fsSync.existsSync(tempFolder)) {
fsSync.rmSync(tempFolder, { recursive: true });
}
}

describe("Kipper CLI 'new'", () => {
beforeEach(async () => {
await fs.mkdir(tempFolder, { recursive: true });
process.chdir(tempFolder);
beforeEach(() => {
createTemp();
});

test
.stdout()
.command(["new", "-d"])
.command(["new", tempFolder, "-d"])
.it("using '-d' (Default Config)", async (ctx) => {
assert.isNotEmpty(ctx.stdout);
assert.include(ctx.stdout, "Using default settings. Skipping setup wizard.");
Expand Down Expand Up @@ -47,8 +58,7 @@ describe("Kipper CLI 'new'", () => {
assert.include(kipConfig, '"resources": []');
});

afterEach(async () => {
await fs.rm(tempFolder, { recursive: true });
process.chdir(originalCwd);
afterEach(() => {
removeTemp();
});
});

0 comments on commit 80fcb57

Please sign in to comment.