Skip to content

Commit eef102b

Browse files
committed
Rename MockMessaging.nextResult() to respondNext()
1 parent 48313d7 commit eef102b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/messaging.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,20 @@ MockMessaging.prototype.autoFlush = function (delay) {
6060
};
6161

6262
MockMessaging.prototype.failNext = function(methodName, err) {
63+
assert(_.isString(methodName), 'methodName must be a string');
6364
assert(err instanceof Error, 'err must be an "Error" object');
6465
this.results[methodName] = err;
6566
};
6667

67-
MockMessaging.prototype.nextResult = function(methodName, result) {
68+
MockMessaging.prototype.respondNext = function(methodName, result) {
69+
assert(_.isString(methodName), 'methodName must be a string');
6870
assert(!_.isUndefined(result), 'result must not be undefined');
6971
assert(!(result instanceof Error), 'result must not be an "Error" object');
7072
this.results[methodName] = result;
7173
};
7274

7375
MockMessaging.prototype.on = function(methodName, callback) {
76+
assert(_.isString(methodName), 'methodName must be a string');
7477
assert(_.isFunction(callback), 'callback must be a function');
7578
this.callbacks[methodName] = callback;
7679
};
@@ -101,9 +104,9 @@ MockMessaging.prototype._invokeOn = function(methodName, args) {
101104
};
102105

103106
MockMessaging.prototype._nextResult = function(type) {
104-
var err = this.results[type];
107+
var result = this.results[type];
105108
delete this.results[type];
106-
return err || null;
109+
return result || null;
107110
};
108111

109112
MockMessaging.prototype._defer = function(sourceMethod, sourceArgs, callback) {

test/unit/messaging.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('MockMessaging', function() {
8888
});
8989

9090
it('can return user defined results', function(done) {
91-
messaging.nextResult('send', 'the result');
91+
messaging.respondNext('send', 'the result');
9292
var thenable = messaging.send({message: 'foo'});
9393
messaging.flush();
9494
thenable.then(function(result) {
@@ -152,7 +152,7 @@ describe('MockMessaging', function() {
152152
});
153153

154154
it('can return user defined results', function(done) {
155-
messaging.nextResult('sendAll', 'the result');
155+
messaging.respondNext('sendAll', 'the result');
156156
var thenable = messaging.sendAll([{message: 'foobar'}]);
157157
messaging.flush();
158158
thenable.then(function(result) {
@@ -223,7 +223,7 @@ describe('MockMessaging', function() {
223223
});
224224

225225
it('can return user defined results', function(done) {
226-
messaging.nextResult('sendMulticast', 'the result');
226+
messaging.respondNext('sendMulticast', 'the result');
227227
var thenable = messaging.sendMulticast({message: 'foobar', tokens: ['t1']});
228228
messaging.flush();
229229
thenable.then(function(result) {

0 commit comments

Comments
 (0)