Merge pull request #975 from andrerod/fix_notifications

974: Fix issue with wrong payload for template notifications
This commit is contained in:
André Rodrigues 2013-08-17 04:10:16 -07:00
Родитель d785abda24 43cd8890c4
Коммит 2238ee2578
2 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -148,7 +148,7 @@ NotificationHubService.prototype.send = function (tags, payload, optionsOrCallba
} }
if (!_.isString(payload)) { if (!_.isString(payload)) {
payload = JSON.stringify({ aps: payload }); payload = JSON.stringify(payload);
} }
if (options && options.headers) { if (options && options.headers) {

Просмотреть файл

@ -34,8 +34,11 @@ var tokenId = '0f744707bebcf74f9b7c25d48e3358945f6aa01da5ddb387462c7eaf61bbad78'
describe('Notification hubs', function () { describe('Notification hubs', function () {
var service; var service;
var suiteUtil; var suiteUtil;
var sandbox;
before(function (done) { before(function (done) {
sandbox = sinon.sandbox.create();
service = azure.createServiceBusService() service = azure.createServiceBusService()
.withFilter(new azure.ExponentialRetryPolicyFilter()); .withFilter(new azure.ExponentialRetryPolicyFilter());
@ -44,6 +47,7 @@ describe('Notification hubs', function () {
}); });
after(function (done) { after(function (done) {
sandbox.restore();
suiteUtil.teardownSuite(done); suiteUtil.teardownSuite(done);
}); });
@ -225,9 +229,17 @@ describe('Notification hubs', function () {
notificationHubService = azure.createNotificationHubService(hubName); notificationHubService = azure.createNotificationHubService(hubName);
suiteUtil.setupService(notificationHubService); suiteUtil.setupService(notificationHubService);
var executeSpy = sandbox.spy(notificationHubService, '_executeRequest');
notificationHubService.send(null, { property: 'value' }, function (err) { notificationHubService.send(null, { property: 'value' }, function (err) {
should.not.exist(err); should.not.exist(err);
// Body
var body = JSON.parse(executeSpy.args[0][1]);
should.exist(body['property']);
body['property'].should.equal('value');
done(); done();
}); });
}); });