Skip to content

Commit

Permalink
Release 1.0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
miqmago committed Feb 24, 2017
1 parent eb35731 commit 7006517
Show file tree
Hide file tree
Showing 3 changed files with 419 additions and 8 deletions.
13 changes: 10 additions & 3 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "node-pushnotifications",
"description": "A cross-platform push service for node.js",
"version": "1.0.14",
"version": "1.0.15",
"author": {
"name": "AppFeel",
"email": "info@appfeel.com"
Expand All @@ -13,7 +13,7 @@
"build": "./node_modules/.bin/babel src -d lib",
"prepublish": "npm run lint && npm test && npm run build",
"lint": "eslint src/**/*.js",
"test-alone": "./node_modules/.bin/_mocha test/ --compilers jsx:babel-core/register --recursive"
"test-alone": "./node_modules/.bin/_mocha test/ --compilers jsx:babel-core/register --recursive -w"
},
"keywords": [
"notifications",
Expand Down Expand Up @@ -54,7 +54,14 @@
"wns": "^0.5.3"
},
"engines": {
"node": "*"
"node": ">= 4.6.0"
},
"eslintConfig": {
"ecmaVersion": 6,
"env": {
"es6": true,
"node": true
}
},
"readmeFilename": "README.md",
"homepage": "https://github.com/appfeel/node-pushnotifications",
Expand Down
47 changes: 47 additions & 0 deletions test/send/sendAPN.js
Expand Up @@ -115,6 +115,53 @@ describe('push-notifications-apn', () => {
});
});

describe('send push notifications successfully (no payload)', () => {
const test = (err, results, done) => {
try {
expect(err).to.equal(null);
results.forEach((result) => {
expect(result.method).to.equal(method);
expect(result.success).to.equal(regIds.length);
expect(result.failure).to.equal(0);
expect(result.message.length).to.equal(regIds.length);
result.message.forEach((message) => {
expect(message).to.have.property('regId');
expect(regIds).to.include(message.regId);
});
});
done(err);
} catch (e) {
done(err || e);
}
};

before(() => {
sendMethod = sinon.stub(apn.Provider.prototype, 'send', (message, _regIds) => {
expect(_regIds).to.be.instanceOf(Array);
_regIds.forEach(regId => expect(regIds).to.include(regId));
expect(message).to.be.instanceOf(apn.Notification);
expect(message).to.have.deep.property('aps.sound', 'ping.aiff');
expect(message).to.have.deep.property('aps.alert.title', data.title);
expect(message).to.have.deep.property('aps.alert.body', data.body);
expect(message).to.have.deep.property('payload').deep.equal({});
return Promise.resolve({
sent: _regIds,
});
});
});

after(() => {
sendMethod.restore();
});

it('all responses should be successful (callback no payload, no sound)', (done) => {
const newData = Object.assign({}, data);
delete newData.custom;
delete newData.sound;
pn.send(regIds, newData, (err, results) => test(err, results, done));
});
});

{
const test = (err, results, done) => {
try {
Expand Down

0 comments on commit 7006517

Please sign in to comment.