Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/protos.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ exports.locals = function(locals) {
* @api public
*/

exports.ready = function() {
exports.ready = function(err) {
if (err) return this.debug('error loading "%s" error="%s"', this.name, err);
this.emit('ready');
};

Expand Down
24 changes: 24 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,4 +633,28 @@ describe('integration', function() {
assert(window.onload === onload);
});
});

describe('#ready', function() {
beforeEach(function() {
integration = new Integration();
});

it('should should emit a ready event', function() {
var called = false;
integration.on('ready', function() {
called = true;
});
integration.ready();
assert(called === true);
});

it('should should not emit a ready event if the integration fails', function() {
var called = false;
integration.on('ready', function() {
called = true;
});
integration.ready(new Error('failed to load'));
assert(called === false);
});
});
});