Fix the "Done not a function" error.

* In init, if `done` was not passed, we called `noOp()` instead of setting a reference to it.
* Added a unit test to check for the problem

fixes #232
This commit is contained in:
Shane Tomlinson 2014-01-17 12:14:03 +00:00
Родитель 1a3ce8c4ad
Коммит d1825814af
2 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -115,7 +115,7 @@ function (_, Backbone, Session) {
},
send: function (command, data, done) {
done = done || noOp();
done = done || noOp;
var outstanding = this.outstandingRequests[command];
if (! outstanding) {

Просмотреть файл

@ -99,6 +99,12 @@ function(mocha, chai, WindowMock, RouterMock, Session, FxDesktopChannel) {
done();
});
});
it('does not except on timeout if callback is not given', function(done) {
// if there is an exception, done is never called.
setTimeout(done, 500);
channel.send('wait-for-response', { key: 'value' });
});
});
describe('on', function() {