From 60857994c3ec2b83be3ddb05a5af95229eb9b997 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Mon, 11 May 2015 17:27:58 -0500 Subject: [PATCH] Add expectation that push notification gets called when sending gems --- package.json | 1 + test/api/api-helper.coffee | 3 ++- test/api/pushNotifications.coffee | 13 +++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f1632763b6..04655f1101 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "rimraf": "^2.2.8", "shelljs": "^0.4.0", "sinon": "^1.12.2", + "sinon-chai": "^2.7.0", "superagent": "~0.15.7", "superagent-defaults": "~0.1.5", "vinyl-source-stream": "^1.0.0", diff --git a/test/api/api-helper.coffee b/test/api/api-helper.coffee index 31a774007d..0c3ae7b580 100644 --- a/test/api/api-helper.coffee +++ b/test/api/api-helper.coffee @@ -12,7 +12,8 @@ global.shared = require("../../common") global.User = require("../../website/src/models/user").model global.chai = require("chai") -global.expect = require("chai").expect +chai.use(require("sinon-chai")) +global.expect = chai.expect ############################## # Nconf config diff --git a/test/api/pushNotifications.coffee b/test/api/pushNotifications.coffee index a2a84e42d0..b40a271fd0 100644 --- a/test/api/pushNotifications.coffee +++ b/test/api/pushNotifications.coffee @@ -68,7 +68,16 @@ describe "Push-Notifications", -> res = { locals: { user: user } } members.sendGift req, res - # @TODO Expectations - done() + + setTimeout -> + # Allow sendGift to finish + expect(pushSpy.sendNotify).to.have.been.calledOnce + expect(pushSpy.sendNotify).to.have.been.calledWith( + recipient, + 'Gifted Gems', + '1 Gems - by ' + user.profile.name + ) + done() + , 100 it "sends a push notification when gifted a subscription"