Skip to content

Commit

Permalink
Ensure that process.stdin.* function exist for test
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Oct 18, 2016
1 parent c6d8406 commit d36ce88
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions test/unit/deployment/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -2864,8 +2864,18 @@ exports['deployment.js.lists'] = {
exports['deployment.js.postRun'] = {
setUp: function(done) {
this.info = sandbox.stub(log, 'info');
this.stdinPipe = sandbox.stub(process.stdin, 'pipe');
this.stdinSetRawMode = sandbox.stub(process.stdin, 'setRawMode');

this.originalProcessStdinProperties = {
pipe: process.stdin.pipe,
setRawMode: process.stdin.setRawMode,
};

this.stdinPipe = sandbox.spy();
this.setRawMode = sandbox.spy();

process.stdin.pipe = this.stdinPipe;
process.stdin.setRawMode = this.setRawMode;

this.notRealTessel = {
connection: {
connectionType: 'LAN',
Expand All @@ -2874,7 +2884,12 @@ exports['deployment.js.postRun'] = {

done();
},

tearDown: function(done) {

process.stdin.pipe = this.originalProcessStdinProperties.pipe;
process.stdin.setRawMode = this.originalProcessStdinProperties.setRawMode;

sandbox.restore();
done();
},
Expand All @@ -2887,8 +2902,8 @@ exports['deployment.js.postRun'] = {
stdin: null
}
}).then(() => {
test.equal(this.stdinPipe.callCount, 1);
test.equal(this.stdinSetRawMode.callCount, 1);
test.equal(process.stdin.pipe.callCount, 1);
test.equal(process.stdin.setRawMode.callCount, 1);
test.done();
});
},
Expand All @@ -2902,8 +2917,8 @@ exports['deployment.js.postRun'] = {
stdin: null
}
}).then(() => {
test.equal(this.stdinPipe.callCount, 0);
test.equal(this.stdinSetRawMode.callCount, 0);
test.equal(process.stdin.pipe.callCount, 0);
test.equal(process.stdin.setRawMode.callCount, 0);
test.done();
});
},
Expand Down

0 comments on commit d36ce88

Please sign in to comment.