Skip to content

Commit 31edbf3

Browse files
committed
Add standard input test for hook template
1 parent 54eff6b commit 31edbf3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/run.test.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require('chai').should();
22
var fs = require('fs');
3+
var execSync = require('child_process').execSync;
34
var gitHooks = require('../lib/git-hooks');
45
var fsHelpers = require('../lib/fs-helpers');
56

@@ -89,11 +90,21 @@ describe('git-hook runner', function () {
8990
});
9091
});
9192

92-
it('should pass standard input to them', function (done) {
93-
gitHooks.run(PRECOMMIT_HOOK_PATH, [], 'I am working properly!', function () {
94-
fs.readFileSync(logFile).toString().should.equal('Hello, world!\n\nI am working properly!\n');
93+
describe('if standard input is passed in', function () {
94+
it('should read it properly', function (done) {
95+
execSync('echo "I am working properly!" | ' + PRECOMMIT_HOOK_PATH);
96+
fs.readFileSync(logFile).toString().trim().should.equal('Hello, world!\n\nI am working properly!');
9597
done();
9698
});
99+
100+
it('should pass it to them', function (done) {
101+
gitHooks.run(PRECOMMIT_HOOK_PATH, [], 'I am working properly!', function () {
102+
fs.readFileSync(logFile).toString().trim()
103+
.should.equal('Hello, world!\n\nI am working properly!');
104+
done();
105+
});
106+
});
107+
97108
});
98109

99110
it('should run a hook with success status', function (done) {

0 commit comments

Comments
 (0)