Make test-cases more generic
This commit is contained in:
parent
8f254ca247
commit
9f77db0198
|
@ -0,0 +1,35 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.3.0] - 2019-12-06
|
||||
|
||||
## [0.2.0] - 2019-09-13
|
||||
|
||||
### Added
|
||||
|
||||
- First feature that is gonna make us money.
|
||||
- Quite a few bugs, sorry in advance!
|
||||
|
||||
### Changed
|
||||
|
||||
- Reworked the login system. You have to provide a password now!
|
||||
|
||||
## [0.1.0] - 2019-09-05
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release :tada:
|
||||
|
||||
[Unreleased]: https://github.com/foo/bar/compare/0.3.0...HEAD
|
||||
|
||||
[0.3.0]: https://github.com/foo/bar/compare/0.2.0...0.3.0
|
||||
|
||||
[0.2.0]: https://github.com/foo/bar/compare/0.1.0...0.2.0
|
||||
|
||||
[0.1.0]: https://github.com/foo/bar/compare/1625533e04119e8496b14d5e18786f150b4fce4d...0.1.0
|
|
@ -0,0 +1,31 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.2.0] - 2019-09-13
|
||||
|
||||
### Added
|
||||
|
||||
- First feature that is gonna make us money.
|
||||
- Quite a few bugs, sorry in advance!
|
||||
|
||||
### Changed
|
||||
|
||||
- Reworked the login system. You have to provide a password now!
|
||||
|
||||
## [0.1.0] - 2019-09-05
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release :tada:
|
||||
|
||||
[Unreleased]: https://github.com/foo/bar/compare/0.2.0...HEAD
|
||||
|
||||
[0.2.0]: https://github.com/foo/bar/compare/0.1.0...0.2.0
|
||||
|
||||
[0.1.0]: https://github.com/foo/bar/compare/1625533e04119e8496b14d5e18786f150b4fce4d...0.1.0
|
|
@ -0,0 +1,4 @@
|
|||
export default {
|
||||
version: '0.3.0',
|
||||
date: '2019-12-06'
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
export default {
|
||||
version: '0.3.0',
|
||||
date: '2019-12-06'
|
||||
};
|
|
@ -1,25 +1,13 @@
|
|||
import formatDate from "../src/formatDate";
|
||||
|
||||
it("should format a date with a single digit day correctly", function() {
|
||||
const date = new Date(Date.parse("Dec 09 2019"));
|
||||
it.each([
|
||||
["Dec 09 2019", "2019-12-09"],
|
||||
["Dec 16 2019", "2019-12-16"],
|
||||
["Jan 09 2019", "2019-01-09"]
|
||||
])("should format '%s' as '%s'", function(given, expected) {
|
||||
const date = new Date(Date.parse(given));
|
||||
|
||||
const formatted = formatDate(date);
|
||||
|
||||
expect(formatted).toEqual("2019-12-09");
|
||||
});
|
||||
|
||||
it("should format a date with a double digit day correctly", function() {
|
||||
const date = new Date(Date.parse("Dec 16 2019"));
|
||||
|
||||
const formatted = formatDate(date);
|
||||
|
||||
expect(formatted).toEqual("2019-12-16");
|
||||
});
|
||||
|
||||
it("should format a date with a single digit month correctly", function() {
|
||||
const date = new Date(Date.parse("Jan 09 2019"));
|
||||
|
||||
const formatted = formatDate(date);
|
||||
|
||||
expect(formatted).toEqual("2019-01-09");
|
||||
expect(formatted).toEqual(expected);
|
||||
});
|
||||
|
|
|
@ -1,18 +1,32 @@
|
|||
import updateChangelog from "../src/updateChangelog";
|
||||
import { read } from "to-vfile";
|
||||
|
||||
it("should update the changelog correctly", async function() {
|
||||
const before = await read("./__tests__/fixtures/CHANGELOG.1.md", {
|
||||
encoding: "utf-8"
|
||||
});
|
||||
const expected = await read("./__tests__/fixtures/CHANGELOG.1.expected.md", {
|
||||
encoding: "utf-8"
|
||||
});
|
||||
interface Fixture {
|
||||
version: string;
|
||||
date: string;
|
||||
}
|
||||
|
||||
const actual = await updateChangelog(before, "0.3.0", "2019-12-06");
|
||||
it.each(["empty_release", "standard"])(
|
||||
`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 actualContent = actual.toString("utf-8");
|
||||
const expectedContent = expected.toString("utf-8");
|
||||
const actual = await updateChangelog(before, release.version, release.date);
|
||||
|
||||
expect(actualContent).toEqual(expectedContent);
|
||||
});
|
||||
const actualContent = actual.toString("utf-8");
|
||||
const expectedContent = expected.toString("utf-8");
|
||||
|
||||
expect(actualContent).toEqual(expectedContent);
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue