Skip to content

Instantly share code, notes, and snippets.

@OJezu
Created February 28, 2014 16:14
Show Gist options
  • Save OJezu/9273850 to your computer and use it in GitHub Desktop.
Save OJezu/9273850 to your computer and use it in GitHub Desktop.
(function(buster, define){
var assert;
assert = buster.assert;
define('monitor-output-test.js', function(require){
var when = require('when');
buster.testCase('when/monitor/console', {
'should output information about rejected promises with no onRejected': function(done){
var output = false;
console._warn = console.warn;
console._log = console.log;
console.warn = function(rejects){
output = true;
assert(rejects);
if(typeof(rejects) == 'object'){
assert.equals(rejects[0].reason, 'something');
assert.equals(rejects[0].message, 'something');
} else {
assert(rejects.match(/\[promises\]/));
}
};
console.log = console.warn;
require('when/monitor/console');
when.reject('something');
setTimeout(function(){ //when/monitor/console uses throttledReporting that outputs at most every 200ms
console.warn = console._warn;
console.log = console._log;
assert(output);
done();
}, 220);
}
});
});
}(
this.buster || require('buster'),
typeof define === 'function' && define.amd ? define : function (id, factory) {
var packageName = id.split(/[\/\-\.]/)[0], pathToRoot = id.replace(/[^\/]+/g, '..');
pathToRoot = pathToRoot.length > 2 ? pathToRoot.substr(3) : pathToRoot;
factory(function (moduleId) {
return require(moduleId.indexOf(packageName) === 0 ? pathToRoot + moduleId.substr(packageName.length) : moduleId);
});
}
// Boilerplate for AMD and Node
));
@OJezu
Copy link
Author

OJezu commented Feb 28, 2014

Test for cujojs/when#266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment