Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

Unescape PR title and fix some nits #37

Merged
merged 3 commits into from
Jul 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions packages/hothouse/__tests__/pullRequest.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* eslint-env jest */
// @flow
import assert from "assert";
import {
createPullRequestTitle,
createPullRequestMessage
} from "../src/pullRequest";

test("createPullRequestTitle can concat package names format as CSV", () => {
const base = {
current: "1.2.3",
currentRange: "^1.2.3",
latest: "3.4.5",
dev: false,
repositoryUrl: null,
compareUrl: null,
releaseNote: null
};

const title = createPullRequestTitle([
{ ...base, name: "hoge" },
{ ...base, name: "foo" },
{ ...base, name: "bar" }
]);
assert.strictEqual(title, "Update hoge, foo, bar to the latest version");
});

test("createPullRequestMessage must present repository link when repositoryUrl is passed", () => {
const body = createPullRequestMessage([
{
name: "@scope/pkg",
current: "1.2.3-beta.30",
currentRange: "^1.2.3",
latest: "2.0.0",
dev: false,
repositoryUrl: "https://github.com/pkg/pkg",
compareUrl: null,
releaseNote: null
}
]);
assert.ok(body.includes("Package: [repository](https://github.com/pkg/pkg)"));
});
test("createPullRequestMessage must not present repository link when repositoryUrl is null", () => {
const body = createPullRequestMessage([
{
name: "@scope/pkg",
current: "1.2.3-beta.30",
currentRange: "^1.2.3",
latest: "2.0.0",
dev: false,
repositoryUrl: null,
compareUrl: null,
releaseNote: null
}
]);
assert.ok(
!body.includes("Package: [repository](https://github.com/pkg/pkg)")
);
});
test("createPullRequestMessage must present compare URL when compareUrl is passed", () => {
const body = createPullRequestMessage([
{
name: "@scope/pkg",
current: "1.2.3-beta.30",
currentRange: "^1.2.3",
latest: "2.0.0",
dev: false,
repositoryUrl: null,
compareUrl: "https://github.com/pkg/pkg/compare/v1.2.3-beta.30...v2.0.0",
releaseNote: null
}
]);
assert.ok(
body.includes(
"* [compare 1.2.3-beta.30 to 2.0.0 diffs](https://github.com/pkg/pkg/compare/v1.2.3-beta.30...v2.0.0)"
)
);
});
test("createPullRequestMessage must not present compare URL when compareUrl is null", () => {
const body = createPullRequestMessage([
{
name: "@scope/pkg",
current: "1.2.3-beta.30",
currentRange: "^1.2.3",
latest: "2.0.0",
dev: false,
repositoryUrl: null,
compareUrl: null,
releaseNote: null
}
]);
assert.ok(
!body.includes(
"* [compare 1.2.3-beta.30 to 2.0.0 diffs](https://github.com/pkg/pkg/compare/v1.2.3-beta.30...v2.0.0)"
)
);
});
test("createPullRequestMessage must present release note when releaseNote is passed", () => {
const body = createPullRequestMessage([
{
name: "@scope/pkg",
current: "1.2.3-beta.30",
currentRange: "^1.2.3",
latest: "2.0.0",
dev: false,
repositoryUrl: null,
compareUrl: null,
releaseNote: "<h2>Some updates</h2>"
}
]);
assert.ok(body.includes("<details>"), body);
assert.ok(body.includes("<h2>Some updates</h2>"), body);
});
test("createPullRequestMessage must not present release note when releaseNote is null", () => {
const body = createPullRequestMessage([
{
name: "@scope/pkg",
current: "1.2.3-beta.30",
currentRange: "^1.2.3",
latest: "2.0.0",
dev: false,
repositoryUrl: null,
compareUrl: null,
releaseNote: null
}
]);
assert.ok(!body.includes("<details>"));
assert.ok(body.includes("Release note is not available"));
});
4 changes: 2 additions & 2 deletions packages/hothouse/src/pullRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const bodyTemplate = `
* Package: {{#repositoryUrl}}[repository]({{&repositoryUrl}}), {{/repositoryUrl}}[npm](https://www.npmjs.com/package/{{&name}})
* Current Version: {{current}}
* Dev: {{dev}}
{{#repositoryUrl}}* [compare {{current}} to {{latest}} diffs]({{&repositoryUrl}}){{/repositoryUrl}}
{{#compareUrl}}* [compare {{current}} to {{latest}} diffs]({{&compareUrl}}){{/compareUrl}}

The version(\`{{latest}}\`) is **not covered** by your current version range(\`{{currentRange}}\`).

{{#releaseNote}}
<details>
<summary>Release Notes</summary>
{{releaseNote}}
{{&releaseNote}}
</details>
{{/releaseNote}}
{{^releaseNote}}
Expand Down