Skip to content

Commit

Permalink
Clarify e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dev2-nomo committed Nov 27, 2023
1 parent 9b5a75f commit 72fbc03
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 25 deletions.
6 changes: 3 additions & 3 deletions test/e2e/build-webon-test/invalid-build-options.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { runCliTestExpectFailure } from "../../test-util/test-util";
import { runE2ETestExpectFailure } from "../../test-util/test-util";
//import { buildWebOn } from "../../src/build-webon/build-webon";
//import { runCliTestExpectFailure } from "../test-util/test-util";
import { getDebugPath } from "../../../src/util/util";

test("assetDir not existing", async () => {
const output = await runCliTestExpectFailure("build some-non-existing-dir");
const output = await runE2ETestExpectFailure("build some-non-existing-dir");
expect(output).toBe(
`error: ${getDebugPath("some-non-existing-dir")} does not exist.\n`
);
});

test("assetDir not a dir", async () => {
const output = await runCliTestExpectFailure("build README.md");
const output = await runE2ETestExpectFailure("build README.md");
expect(output).toBe(
`error: ${getDebugPath("README.md")} is not a directory.\n`
);
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/deploy-webon-test/invalid-deploy-options.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { runCliTestExpectFailure } from "../../test-util/test-util";
import { runE2ETestExpectFailure } from "../../test-util/test-util";
import { getDebugPath } from "../../../src/util/util";

test("archive not existing", async () => {
const output = await runCliTestExpectFailure(
const output = await runE2ETestExpectFailure(
"deploy some-non-existing-archive"
);
expect(output).toBe(
Expand All @@ -11,6 +11,6 @@ test("archive not existing", async () => {
});

test("archive not a file", async () => {
const output = await runCliTestExpectFailure("deploy src");
const output = await runE2ETestExpectFailure("deploy src");
expect(output).toBe(`error: ${getDebugPath("src")} is a directory.\n`);
});
21 changes: 8 additions & 13 deletions test/e2e/help-test/help.test.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
import {
runCliTest,
runCliTestExpectFailure
} from "../../test-util/test-util";
import { runE2ETest, runE2ETestExpectFailure } from "../../test-util/test-util";

test("--help", async () => {
const output = await runCliTest(`--help`, {
pwd: "/"
const output = await runE2ETest(`--help`, {
pwd: "/",
});
expect(output).toContain("Usage: nomo-webon-cli");
});

test("-h", async () => {
const output = await runCliTest(`-h`, {
pwd: "/"
const output = await runE2ETest(`-h`, {
pwd: "/",
});
expect(output).toContain("Usage: nomo-webon-cli");
});

test("no arguments", async () => {
const output = await runCliTestExpectFailure("");
expect(output).toContain(
"Usage: nomo-webon-cli"
);
const output = await runE2ETestExpectFailure("");
expect(output).toContain("Usage: nomo-webon-cli");
});

test("unknown command", async () => {
const output = await runCliTestExpectFailure(`jivduns bhbd`);
const output = await runE2ETestExpectFailure(`jivduns bhbd`);
expect(output).toBe(
"error: unknown command 'jivduns'. See 'nomo-webon-cli --help'.\n"
);
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/help-test/version.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { runCliTest } from "../../test-util/test-util";
import { runE2ETest } from "../../test-util/test-util";

test("--version", async () => {
const output = await runCliTest(`--version`, {
const output = await runE2ETest(`--version`, {
pwd: "/",
});
expect(output).toContain("0.");
});

test("-v", async () => {
const output = await runCliTest(`-v`);
const output = await runE2ETest(`-v`);
expect(output).toContain("0.");
});
5 changes: 2 additions & 3 deletions test/test-util/test-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ export function buildCliCommand(args: string) {
}
}

export async function runCliTest(
export async function runE2ETest(
args: string,
options?: { pwd?: string; maxTime?: number }
): Promise<string> {
const cmd = buildCliCommand(args);
return await runCommand(cmd, options?.pwd);
}


export async function runCliTestExpectFailure(
export async function runE2ETestExpectFailure(
args: string,
pwd?: string
): Promise<string> {
Expand Down

0 comments on commit 72fbc03

Please sign in to comment.