action-gh-release/__tests__/util.test.ts

50 lines
1.5 KiB
TypeScript
Raw Permalink Normal View History

import { isTag, paths, parseConfig, parseInputFiles } from "../src/util";
2019-09-09 12:20:59 +00:00
import * as assert from "assert";
2019-09-09 08:10:07 +00:00
2019-09-09 12:20:59 +00:00
describe("util", () => {
describe("parseInputFiles", () => {
it("parses empty strings", () => {
assert.deepStrictEqual(parseInputFiles(""), []);
});
it("parses comma-delimited strings", () => {
assert.deepStrictEqual(parseInputFiles("foo,bar"), ["foo", "bar"]);
});
it("parses newline and comma-delimited (and then some)", () => {
assert.deepStrictEqual(
parseInputFiles("foo,bar\nbaz,boom,\n\ndoom,loom "),
["foo", "bar", "baz", "boom", "doom", "loom"]
);
});
});
describe("parseConfig", () => {
it("parses basic config", () => {
assert.deepStrictEqual(parseConfig({}), {
github_ref: "",
github_repository: "",
github_token: "",
input_body: undefined,
input_body_path: undefined,
input_draft: false,
input_files: [],
input_name: undefined
});
});
});
2019-09-09 12:20:59 +00:00
describe("isTag", () => {
it("returns true for tags", async () => {
assert.equal(isTag("refs/tags/foo"), true);
2019-09-09 08:10:07 +00:00
});
2019-09-09 12:20:59 +00:00
it("returns false for other kinds of refs", async () => {
assert.equal(isTag("refs/heads/master"), false);
});
});
2019-09-09 08:10:07 +00:00
2019-09-09 12:20:59 +00:00
describe("paths", () => {
it("resolves files given a set of paths", async () => {
assert.deepStrictEqual(paths(["tests/data/**/*"]), [
"tests/data/foo/bar.txt"
]);
2019-09-09 08:10:07 +00:00
});
2019-09-09 12:20:59 +00:00
});
});