Add test for push notification when gems are sent

This commit is contained in:
Blade Barringer 2015-05-10 20:39:11 -05:00
parent c219df2a9d
commit d4a296870b
2 changed files with 33 additions and 1 deletions

View file

@ -102,6 +102,7 @@
"mongoskin": "~0.6.1",
"phantomjssmith": "~0.5.4",
"protractor": "~2.0.0",
"rewire": "^2.3.3",
"rimraf": "^2.2.8",
"shelljs": "^0.4.0",
"sinon": "^1.12.2",

View file

@ -1,6 +1,8 @@
'use strict'
app = require("../../website/src/server")
rewire = require('rewire')
sinon = require('sinon')
describe "Push-Notifications", ->
before (done) ->
@ -23,6 +25,8 @@ describe "Push-Notifications", ->
describe "Events that send push notifications", ->
pushSpy = sinon.spy()
context "Challenges", ->
it "sends a push notification when you win a challenge"
@ -38,7 +42,34 @@ describe "Push-Notifications", ->
it "sends a push notification when invited to a quest"
context "Gifts", ->
recipient = null
members = rewire("../../website/src/controllers/members")
members.__set__('pushNotify', pushSpy)
members.sendMessage = -> true
it "sends a push notification when gifted gems"
before (done) ->
registerNewUser (err, _user) ->
recipient = _user
user.balance = 4
members.__set__ 'fetchMember', (id) -> return (cb) -> cb(null, recipient)
done()
, false
it "sends a push notification when gifted gems", (done) ->
req = {
params: { uuid: "uuid" },
body: {
type: 'gems',
gems: { amount: 1 }
}
}
res = { locals: { user: user } }
members.sendGift req, res
expect(pushSpy.calledOnce).to.be.ok
done()
it "sends a push notification when gifted a subscription"