Created
February 28, 2014 16:14
-
-
Save OJezu/9273850 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(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 | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test for cujojs/when#266