Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoTheissen committed Sep 23, 2021
1 parent 84e53b0 commit 3ec05ca
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/changelog.sh → lib/changelog.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
remote=$(git remote show origin | grep -P -o "(?<=Push URL: ).*")
folder=$(mktemp -d)
git log | node tools/changelog >$folder/CHANGELOG.md
git log | node lib/changelog >$folder/CHANGELOG.md
cd $folder
git init -b main
git add .
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"scripts": {
"build": "node lib/transform.js",
"changelog": "./tools/changelog.sh",
"changelog": "./lib/changelog.sh",
"test": "c8 -r html -r text mocha",
"watch": "mocha --watch"
},
Expand Down
24 changes: 24 additions & 0 deletions test/changelog.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const assert = require("assert");
const {spawn} = require("child_process");
const fs = require("fs");
const transform = require("../lib/changelog.js");

describe("Changelog", function () {
it("Convert git log to changelog", function () {
var markdown = "";
var proc = spawn("node", ["lib/changelog"], {cwd: __dirname + "/.."});
proc.stdout.on("data", function(chunk) {
markdown += chunk;
})
.on("end", function() {
assert.deepStrictEqual(markdown.split("\n"), [
"# Thu Sep 16 17:19:02 2021 +0200",
"- All terms were deprecated",
"- 100 new terms were introduced",
""
]);
process.exit(0);
});
fs.createReadStream("test/gitlog.txt").pipe(proc.stdin);
});
});
25 changes: 25 additions & 0 deletions test/gitlog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
commit 0c620c74d1c738e98f270c809ea6f347d5106e7c
Author: Ralf Handl <[email protected]>
Date: Fri Sep 17 11:00:09 2021 +0200

Update README.md (#155)

* Update README.md

Co-authored-by: Heiko Theißen <[email protected]>

commit c231de3dbb043eae0deed124851055712da6ff59
Author: Heiko Theißen <[email protected]>
Date: Thu Sep 16 17:24:48 2021 +0200

Temporal vocabulary (#146)

commit 122dff83ef4f139e3361e5af557519c898ee81bd
Author: Ralf Handl <[email protected]>
Date: Thu Sep 16 17:19:02 2021 +0200

Temporal: example for timeline with object key (#154)

CHANGELOG
- All terms were deprecated
- 100 new terms were introduced

0 comments on commit 3ec05ca

Please sign in to comment.