Skip to content

Commit

Permalink
test: make repl-autolibs check that the callback was invoked
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Apr 6, 2012
1 parent ca8dea8 commit 8752cee
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/simple/test-repl-autolibs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ var testMe = repl.start('', putIn, null, true);
test1();

function test1(){
var gotWrite = false;
putIn.write = function (data) {
gotWrite = true;
if (data.length) {
// inspect output matches repl output
assert.equal(data, util.inspect(require('fs'), null, null, false) + '\n');
Expand All @@ -53,11 +55,15 @@ function test1(){
test2();
}
};
assert(!gotWrite);
putIn.run(['fs']);
assert(gotWrite);
}

function test2(){
var gotWrite = false;
putIn.write = function(data) {
gotWrite = true;
if (data.length) {
// repl response error message
assert.equal(data.indexOf('A different'), 0);
Expand All @@ -67,5 +73,7 @@ function test2(){
};
var val = {};
global.url = val;
assert(!gotWrite);
putIn.run(['url']);
assert(gotWrite);
}

0 comments on commit 8752cee

Please sign in to comment.