generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 36
/
updateChangelog.test.ts
48 lines (43 loc) · 1.24 KB
/
updateChangelog.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import updateChangelog from "../src/updateChangelog";
import { read, write } from "to-vfile";
interface Fixture {
tag: string;
version: string;
date: string;
genesisHash: string;
owner: string;
repo: string;
}
it.each(["empty_release", "standard", "first_release", "lowercase_link_reference", "tag_release", "tag_on_tag"])(
`should update %s changelog`,
async function(testcase) {
const before = await read(`./__tests__/fixtures/${testcase}/CHANGELOG.md`, {
encoding: "utf-8"
});
const expected = await read(
`./__tests__/fixtures/${testcase}/CHANGELOG.expected.md`,
{
encoding: "utf-8"
}
);
const release: Fixture = await import(
`./fixtures/${testcase}/fixture`
).then(module => module.default);
const actual = await updateChangelog(
before,
release.tag,
release.version,
release.date,
release.genesisHash,
release.owner,
release.repo
);
actual.path = `./__tests__/fixtures/${testcase}/CHANGELOG.actual.md`;
await write(actual, {
encoding: "utf-8"
});
const actualContent = actual.toString("utf-8");
const expectedContent = expected.toString("utf-8");
expect(actualContent).toEqual(expectedContent);
}
);