Skip to content

Commit

Permalink
make test-all work for jasmine-async
Browse files Browse the repository at this point in the history
  • Loading branch information
Moshe Kolodny committed Apr 23, 2015
1 parent 285db6f commit 184a9b1
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions jasmine-async/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
var inject = (function() {
var assert = require('assert');
var thingsToDo = [];
var runs = function(runFn) {
thingsToDo.push({type: 'run', todo: runFn});
};
var waitsFor = function(waitsForFn) {
thingsToDo.push({type: 'waitsFor', todo: waitsForFn});
};
var it = function(desc, fn) {
fn();
assert.equal(thingsToDo[0].type, 'run');
assert.equal(thingsToDo[1].type, 'waitsFor');
assert.equal(thingsToDo[2].type, 'run');
thingsToDo[0].todo();
next();
function next() {
if (thingsToDo[1].todo()) {
thingsToDo[2].todo();
} else {
setTimeout(next, 1);
}
}
};

}).toString().split('\n').slice(1, -1).join('\n');

var assert = require('assert');
var jasmineAsync = require('./');
var fs = require('fs');
var indexContents = fs.readFileSync(__dirname + '/index.js').toString();
fs.writeFileSync(__dirname + '/index__TMP__.js', indexContents + inject);
var jasmineAsync = require(__dirname + '/index__TMP__.js');
fs.unlinkSync(__dirname + '/index__TMP__.js');

var mochaIt = it;

Expand All @@ -26,26 +57,3 @@ describe('jasmineAsync', function() {
});

});

it = function(desc, fn) {
var thingsToDo = [];
global.runs = function(runFn) {
thingsToDo.push({type: 'run', todo: runFn});
};
global.waitsFor = function(waitsForFn) {
thingsToDo.push({type: 'waitsFor', todo: waitsForFn});
};
fn();
assert.equal(thingsToDo[0].type, 'run');
assert.equal(thingsToDo[1].type, 'waitsFor');
assert.equal(thingsToDo[2].type, 'run');
thingsToDo[0].todo();
next();
function next() {
if (thingsToDo[1].todo()) {
thingsToDo[2].todo();
} else {
setTimeout(next, 1);
}
}
};

0 comments on commit 184a9b1

Please sign in to comment.