Rework how invite expiry functions.

This commit is contained in:
Shane Kilkelly
2016-08-12 14:40:59 +01:00
parent d547bff4e5
commit e53394919f
4 changed files with 39 additions and 12 deletions
@@ -60,9 +60,10 @@ describe 'NotificationsHandler', ->
@key = "some key here"
@messageOpts = {value:12344}
@templateKey = "renderThisHtml"
@expiry = null
it "should post the message over", (done)->
@handler.createNotification user_id, @key, @templateKey, @messageOpts, =>
@handler.createNotification user_id, @key, @templateKey, @messageOpts, @expiry, =>
args = @request.args[0][0]
args.uri.should.equal "#{notificationUrl}/user/#{user_id}"
args.timeout.should.equal 1000
@@ -70,6 +71,22 @@ describe 'NotificationsHandler', ->
assert.deepEqual(args.json, expectedJson)
done()
describe 'when expiry date is supplied', ->
beforeEach ->
@key = "some key here"
@messageOpts = {value:12344}
@templateKey = "renderThisHtml"
@expiry = new Date()
it 'should post the message over with expiry field', (done) ->
@handler.createNotification user_id, @key, @templateKey, @messageOpts, @expiry, =>
args = @request.args[0][0]
args.uri.should.equal "#{notificationUrl}/user/#{user_id}"
args.timeout.should.equal 1000
expectedJson = {key:@key, templateKey:@templateKey, messageOpts:@messageOpts, expires: @expiry}
assert.deepEqual(args.json, expectedJson)
done()
describe "markAsReadByKeyOnly", ->
beforeEach ->
@key = "some key here"