Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #849 from charlierudolph/cr-splitTests
convert tests to mocha
- Loading branch information
Showing
6 changed files
with
78 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = function (config) { | ||
config.set({ | ||
browsers: ['Firefox'], | ||
files: ['mocha_test/*.js'], | ||
frameworks: ['browserify', 'mocha'], | ||
preprocessors: { | ||
'mocha_test/*.js': ['browserify'] | ||
}, | ||
reporters: ['mocha'], | ||
singleRun: true | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var async = require('../lib/async'); | ||
var expect = require('chai').expect; | ||
var isBrowser = require('./support/is_browser'); | ||
|
||
describe('forever', function(){ | ||
context('function is asynchronous', function(){ | ||
it('executes the function over and over until it yields an error', function(done){ | ||
var counter = 0; | ||
addOne = function (callback) { | ||
counter++; | ||
if (counter === 50) { | ||
return callback('too big!'); | ||
} | ||
async.setImmediate(function () { | ||
callback(); | ||
}); | ||
} | ||
async.forever(addOne, function (err) { | ||
expect(err).to.eql('too big!'); | ||
expect(counter).to.eql(50); | ||
done(); | ||
}); | ||
}) | ||
}); | ||
|
||
context('function is synchronous', function(){ | ||
it('does not cause a stack overflow', function(done){ | ||
if (isBrowser()) return done(); // this will take forever in a browser | ||
var counter = 0; | ||
function addOne(callback) { | ||
counter++; | ||
if (counter === 50000) { // needs to be huge to potentially overflow stack in node | ||
return callback('too big!'); | ||
} | ||
callback(); | ||
} | ||
async.forever(addOne, function (err) { | ||
expect(err).to.eql('too big!'); | ||
expect(counter).to.eql(50000); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = function() { | ||
return (typeof process === "undefined") || | ||
(process + "" !== "[object process]"); // browserify | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters