Skip to content

Commit

Permalink
Merge pull request #237 from TobyAndToby/tb/move-test-config-files
Browse files Browse the repository at this point in the history
Tb/move test config files
  • Loading branch information
tobysmith568 committed Nov 28, 2023
2 parents c139afd + 316d2be commit 8cd7b24
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 46 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { exec } from "child_process";
import fs from "fs/promises";
import { promisify } from "util";
import * as OutputFileNames from "../output-filenames.js";
import { output as outputFileName } from "./config.js";

const execAsync = promisify(exec);

describe("cli", () => {
beforeEach(async () => {});

it("should match snapshot when content is appended", async () => {
const configPath = "./.config/append-config.js";
const outputPath = OutputFileNames.AppendConfig;
const configPath = "./test/cli/append/config.js";

await execAsync(`npx generate-license-file -c ${configPath}`);

const result = await fs.readFile(outputPath, "utf8");
const result = await fs.readFile(outputFileName, "utf8");
expect(result).toMatchSnapshot();

await fs.unlink(outputPath);
await fs.unlink(outputFileName);
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const OutputFileNames = require("../test/output-filenames");

module.exports = {
inputs: ["./package.json"],
output: OutputFileNames.AppendConfig,
output: "append-config-output.txt",

// Test that appendices are used in the output file.
append: ["./append-content.txt"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const OutputFileNames = require("../test/output-filenames");

module.exports = {
inputs: ["./package.json"],
output: OutputFileNames.ExcludeConfig,
output: "exclude-config-output.txt",

// Test that exclusions are not included in the output file.
exclude: ["dep-five@1.0.0"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { exec } from "child_process";
import fs from "fs/promises";
import { promisify } from "util";
import * as OutputFileNames from "../output-filenames.js";
import { output as outputFileName } from "./config.js";

const execAsync = promisify(exec);

describe("cli", () => {
beforeEach(async () => {});

it("should match snapshot when content is excluded", async () => {
const configPath = "./.config/exclude-config.js";
const outputPath = OutputFileNames.ExcludeConfig;
const configPath = "./test/cli/exclude/config.js";

await execAsync(`npx generate-license-file -c ${configPath}`);

const result = await fs.readFile(outputPath, "utf8");
const result = await fs.readFile(outputFileName, "utf8");
expect(result).toMatchSnapshot();

await fs.unlink(outputPath);
await fs.unlink(outputFileName);
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const OutputFileNames = require("../test/output-filenames");

module.exports = {
// Test that the input and output config is picked up from config correctly.
inputs: ["./package.json"],
output: OutputFileNames.InputsOutputConfig,
output: "inputs-output-config-output.txt",
};
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { exec } from "child_process";
import fs from "fs/promises";
import { promisify } from "util";
import * as OutputFileNames from "../output-filenames.js";
import { output as outputFileName } from "./config.js";

const execAsync = promisify(exec);

describe("cli", () => {
beforeEach(async () => {});

it("should match snapshot when inputs and outputs are provided via config file", async () => {
const configPath = "./.config/inputs-output-config.js";
const outputPath = OutputFileNames.InputsOutputConfig;
const configPath = "./test/cli/inputs-output/config.js";

await execAsync(`npx generate-license-file -c ${configPath}`);

const result = await fs.readFile(outputPath, "utf8");
const result = await fs.readFile(outputFileName, "utf8");
expect(result).toMatchSnapshot();

await fs.unlink(outputPath);
await fs.unlink(outputFileName);
});
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const OutputFileNames = require("../test/output-filenames");

module.exports = {
inputs: ["./package.json"],
output: OutputFileNames.ReplacementConfig,
output: "replacement-config-output.txt",

// Test that replacements are used in the output file.
replace: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { exec } from "child_process";
import fs from "fs/promises";
import { promisify } from "util";
import * as OutputFileNames from "../output-filenames.js";
import { output as outputFileName } from "./config.js";

const execAsync = promisify(exec);

describe("cli", () => {
beforeEach(async () => {});

it("should match snapshot when a package is replaced", async () => {
const configPath = "./.config/replacement-config.js";
const outputPath = OutputFileNames.ReplacementConfig;
const configPath = "./test/cli/replacement/config.js";

await execAsync(`npx generate-license-file -c ${configPath}`);

const result = await fs.readFile(outputPath, "utf8");
const result = await fs.readFile(outputFileName, "utf8");
expect(result).toMatchSnapshot();

await fs.unlink(outputPath);
await fs.unlink(outputFileName);
});
});
14 changes: 0 additions & 14 deletions e2e/config-file/test/output-filenames.js

This file was deleted.

0 comments on commit 8cd7b24

Please sign in to comment.