sqs-consumer
Advanced tools
Comparing version 3.1.3 to 3.2.0
@@ -114,2 +114,4 @@ 'use strict'; | ||
this.sqs.receiveMessage(receiveParams, this._handleSqsResponseBound); | ||
} else { | ||
this.emit('stopped'); | ||
} | ||
@@ -116,0 +118,0 @@ }; |
{ | ||
"name": "sqs-consumer", | ||
"version": "3.1.3", | ||
"version": "3.2.0", | ||
"description": "Build SQS-based Node applications without the boilerplate", | ||
@@ -32,3 +32,3 @@ "main": "index.js", | ||
"mocha": "^2.0.1", | ||
"codeclimate-test-reporter": "0.3.1", | ||
"codeclimate-test-reporter": "0.3.3", | ||
"sinon": "^1.10.3" | ||
@@ -35,0 +35,0 @@ }, |
@@ -114,1 +114,2 @@ # sqs-consumer | ||
|`message_processed`|`message`|Fired when a message is successfully processed and removed from the queue.| | ||
|`stopped`|None|Fired when the consumer finally stops its work.| |
@@ -338,6 +338,8 @@ 'use strict'; | ||
describe('.stop', function () { | ||
it('stops the consumer polling for messages', function (done) { | ||
beforeEach(function () { | ||
sqs.receiveMessage.onSecondCall().yieldsAsync(null, response); | ||
sqs.receiveMessage.onThirdCall().returns(); | ||
}); | ||
it('stops the consumer polling for messages', function (done) { | ||
consumer.start(); | ||
@@ -351,3 +353,49 @@ consumer.stop(); | ||
}); | ||
it('fires a stopped event when last poll occurs after stopping', function (done) { | ||
var handleStop = sinon.stub().returns(); | ||
consumer.on('stopped', handleStop); | ||
consumer.start(); | ||
consumer.stop(); | ||
setTimeout(function () { | ||
sinon.assert.calledOnce(handleStop); | ||
done(); | ||
}, 10); | ||
}); | ||
it('fires a stopped event only once when stopped multiple times', function (done) { | ||
var handleStop = sinon.stub().returns(); | ||
consumer.on('stopped', handleStop); | ||
consumer.start(); | ||
consumer.stop(); | ||
consumer.stop(); | ||
consumer.stop(); | ||
setTimeout(function () { | ||
sinon.assert.calledOnce(handleStop); | ||
done(); | ||
}, 10); | ||
}); | ||
it('fires a stopped event a second time if started and stopped twice', function (done) { | ||
var handleStop = sinon.stub().returns(); | ||
consumer.on('stopped', handleStop); | ||
consumer.start(); | ||
consumer.stop(); | ||
consumer.start(); | ||
consumer.stop(); | ||
setTimeout(function () { | ||
sinon.assert.calledTwice(handleStop); | ||
done(); | ||
}, 10); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23094
485
115