2020-02-15 11:19:02 +05:30
|
|
|
import { morph } from "mock-env";
|
|
|
|
import getInputs from "../src/getInputs";
|
|
|
|
|
2023-06-03 01:10:42 +05:30
|
|
|
test("version or tag is required", function () {
|
2020-02-15 14:59:25 +05:30
|
|
|
expect(() => morph(getInputs, { GITHUB_REPOSITORY: "foo/bar" })).toThrow();
|
2020-02-15 11:19:02 +05:30
|
|
|
});
|
|
|
|
|
2023-06-03 01:10:42 +05:30
|
|
|
test("tag is used before version", function () {
|
2021-10-05 21:17:28 +05:30
|
|
|
const inputs = morph(getInputs, {
|
|
|
|
INPUT_TAG: "0.7.0",
|
|
|
|
INPUT_VERSION: "0.6.0",
|
2023-06-03 01:10:42 +05:30
|
|
|
GITHUB_REPOSITORY: "foo/bar",
|
2021-10-05 21:17:28 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(inputs).toHaveProperty("tag", "0.7.0");
|
|
|
|
expect(inputs).toHaveProperty("version", "0.7.0");
|
|
|
|
});
|
|
|
|
|
2023-06-03 01:10:42 +05:30
|
|
|
test("version fallback works", function () {
|
2020-02-15 11:19:02 +05:30
|
|
|
const inputs = morph(getInputs, {
|
2020-02-15 14:59:25 +05:30
|
|
|
INPUT_VERSION: "0.6.0",
|
2023-06-03 01:10:42 +05:30
|
|
|
GITHUB_REPOSITORY: "foo/bar",
|
2020-02-15 11:19:02 +05:30
|
|
|
});
|
|
|
|
|
2021-10-05 21:17:28 +05:30
|
|
|
expect(inputs).toHaveProperty("tag", "0.6.0");
|
|
|
|
expect(inputs).toHaveProperty("version", "0.6.0");
|
|
|
|
});
|
|
|
|
|
2023-06-03 01:10:42 +05:30
|
|
|
test("can parse prefixed tag", function () {
|
2021-10-05 21:17:28 +05:30
|
|
|
const inputs = morph(getInputs, {
|
|
|
|
INPUT_TAG: "v0.6.0",
|
2023-06-03 01:10:42 +05:30
|
|
|
GITHUB_REPOSITORY: "foo/bar",
|
2021-10-05 21:17:28 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(inputs).toHaveProperty("tag", "v0.6.0");
|
|
|
|
expect(inputs).toHaveProperty("version", "0.6.0");
|
|
|
|
});
|
|
|
|
|
2023-06-03 01:10:42 +05:30
|
|
|
test("date is optional but has a default", function () {
|
2021-10-05 21:17:28 +05:30
|
|
|
const inputs = morph(getInputs, {
|
|
|
|
INPUT_TAG: "0.6.0",
|
2023-06-03 01:10:42 +05:30
|
|
|
GITHUB_REPOSITORY: "foo/bar",
|
2021-10-05 21:17:28 +05:30
|
|
|
});
|
|
|
|
|
2020-02-15 11:19:02 +05:30
|
|
|
expect(inputs).toHaveProperty("version", "0.6.0");
|
|
|
|
expect(inputs).toHaveProperty("date");
|
|
|
|
});
|
|
|
|
|
2023-06-03 01:10:42 +05:30
|
|
|
test("parses date into ISO8601", function () {
|
2020-02-15 11:19:02 +05:30
|
|
|
const inputs = morph(getInputs, {
|
2021-10-05 21:17:28 +05:30
|
|
|
INPUT_TAG: "0.6.0",
|
2023-06-03 01:10:42 +05:30
|
|
|
INPUT_DATE: "Dec 09 2019",
|
2020-02-15 11:19:02 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(inputs).toHaveProperty("date", "2019-12-09");
|
|
|
|
});
|
|
|
|
|
2023-06-03 01:10:42 +05:30
|
|
|
test("parses GITHUB_REPOSITORY into owner and repo", function () {
|
2020-02-15 14:59:25 +05:30
|
|
|
const inputs = morph(getInputs, {
|
2021-10-05 21:17:28 +05:30
|
|
|
INPUT_TAG: "0.6.0",
|
2023-06-03 01:10:42 +05:30
|
|
|
GITHUB_REPOSITORY: "foo/bar",
|
2020-02-15 14:59:25 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(inputs).toHaveProperty("owner", "foo");
|
|
|
|
expect(inputs).toHaveProperty("repo", "bar");
|
|
|
|
});
|
|
|
|
|
2023-06-03 01:10:42 +05:30
|
|
|
test("can handle ISO8601 date", function () {
|
2020-02-15 11:19:02 +05:30
|
|
|
const inputs = morph(getInputs, {
|
2021-10-05 21:17:28 +05:30
|
|
|
INPUT_TAG: "0.6.0",
|
2023-06-03 01:10:42 +05:30
|
|
|
INPUT_DATE: "2019-12-09",
|
2020-02-15 11:19:02 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(inputs).toHaveProperty("date", "2019-12-09");
|
|
|
|
});
|
2020-09-22 10:06:08 +05:30
|
|
|
|
2023-06-03 01:10:42 +05:30
|
|
|
test("changelog path is optional but has a default", function () {
|
2020-09-22 10:06:08 +05:30
|
|
|
const inputs = morph(getInputs, {
|
2021-10-05 21:17:28 +05:30
|
|
|
INPUT_TAG: "0.6.0",
|
2023-06-03 01:10:42 +05:30
|
|
|
GITHUB_REPOSITORY: "foo/bar",
|
2020-09-22 10:06:08 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(inputs).toHaveProperty("changelogPath", "./CHANGELOG.md");
|
|
|
|
});
|
|
|
|
|
2023-06-03 01:10:42 +05:30
|
|
|
test("parse changelog path from input", function () {
|
2020-09-22 10:06:08 +05:30
|
|
|
const inputs = morph(getInputs, {
|
2021-10-05 21:17:28 +05:30
|
|
|
INPUT_TAG: "0.6.0",
|
2020-09-22 10:06:08 +05:30
|
|
|
GITHUB_REPOSITORY: "foo/bar",
|
2023-06-03 01:10:42 +05:30
|
|
|
INPUT_CHANGELOGPATH: "./foo/bar/CHANGELOG.md",
|
2020-09-22 10:06:08 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
expect(inputs).toHaveProperty("changelogPath", "./foo/bar/CHANGELOG.md");
|
|
|
|
});
|