|
@@ -72,11 +72,22 @@ describe 'Notifications Tests', ->
|
|
|
it 'should fail insert of existing notification key', (done)->
|
|
it 'should fail insert of existing notification key', (done)->
|
|
|
@insertStub.callsArgWith(1, null)
|
|
@insertStub.callsArgWith(1, null)
|
|
|
@countStub.callsArgWith(1, null, 1)
|
|
@countStub.callsArgWith(1, null, 1)
|
|
|
-
|
|
|
|
|
|
|
+ @notifications.removeNotificationKey = sinon.stub()
|
|
|
@notifications.addNotification user_id, @stubbedNotification, (err)=>
|
|
@notifications.addNotification user_id, @stubbedNotification, (err)=>
|
|
|
@insertStub.calledWith(@expectedDocument).should.equal false
|
|
@insertStub.calledWith(@expectedDocument).should.equal false
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
|
|
+ describe "when key already exists but override is passed", (done)->
|
|
|
|
|
+
|
|
|
|
|
+ it "should delete the old key and insert the new one", ->
|
|
|
|
|
+ @insertStub.callsArgWith(1, null)
|
|
|
|
|
+ @countStub.callsArgWith(1, null, 1)
|
|
|
|
|
+ @stubbedNotification.override = true
|
|
|
|
|
+ @notifications.addNotification user_id, @stubbedNotification, (err)=>
|
|
|
|
|
+ assert.deepEqual(@insertStub.lastCall.args[0], @expectedDocument)
|
|
|
|
|
+ @notifications.removeNotificationKey.calledWith(user_id, @stubbedNotification.key).should.equal true
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
describe 'when the notification is set to expire', () ->
|
|
describe 'when the notification is set to expire', () ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
@stubbedNotification = {
|
|
@stubbedNotification = {
|