From 3b2adec979bd6be93e1f1bf22779a370bb887e47 Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Sun, 19 Mar 2017 10:45:19 -0400 Subject: [PATCH 1/5] Adds tests for making sure package is sane --- spec/APNS.spec.js | 2 +- spec/GCM.spec.js | 2 +- spec/ParsePushAdapter.spec.js | 15 ++++++++++++--- src/APNS.js | 2 +- src/GCM.js | 1 - src/ParsePushAdapter.js | 1 - 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/spec/APNS.spec.js b/spec/APNS.spec.js index 98f346be..c2da41a8 100644 --- a/spec/APNS.spec.js +++ b/spec/APNS.spec.js @@ -1,4 +1,4 @@ -var APNS = require('../src/APNS'); +var APNS = require('../src/APNS').default; var Parse = require('parse/node'); describe('APNS', () => { diff --git a/spec/GCM.spec.js b/spec/GCM.spec.js index 7f53f296..2414ed71 100644 --- a/spec/GCM.spec.js +++ b/spec/GCM.spec.js @@ -1,4 +1,4 @@ -var GCM = require('../src/GCM'); +var GCM = require('../src/GCM').default; function mockSender(gcm) { return spyOn(gcm.sender, 'send').and.callFake(function(message, options, timeout, cb) { diff --git a/spec/ParsePushAdapter.spec.js b/spec/ParsePushAdapter.spec.js index da3cf87e..5b8e0fbb 100644 --- a/spec/ParsePushAdapter.spec.js +++ b/spec/ParsePushAdapter.spec.js @@ -1,7 +1,8 @@ -var ParsePushAdapter = require('../src/index').ParsePushAdapter; +var ParsePushAdapterPackage = require('../src/index'); +var ParsePushAdapter = ParsePushAdapterPackage.ParsePushAdapter; var randomString = require('../src/PushAdapterUtils').randomString; -var APNS = require('../src/APNS'); -var GCM = require('../src/GCM'); +var APNS = require('../src/APNS').default; +var GCM = require('../src/GCM').default; var MockAPNConnection = require('./MockAPNConnection'); describe('ParsePushAdapter', () => { @@ -14,6 +15,14 @@ describe('ParsePushAdapter', () => { jasmine.restoreLibrary('apn', 'Connection'); }); + it('properly export the module', () => { + expect(typeof ParsePushAdapterPackage.default).toBe('function'); + expect(typeof ParsePushAdapterPackage.ParsePushAdapter).toBe('function'); + expect(typeof ParsePushAdapterPackage.APNS).toBe('function'); + expect(typeof ParsePushAdapterPackage.GCM).toBe('function'); + expect(typeof ParsePushAdapterPackage.utils).toBe('object'); + }); + it('can be initialized', (done) => { // Make mock config var pushConfig = { diff --git a/src/APNS.js b/src/APNS.js index d76ff027..37708b77 100644 --- a/src/APNS.js +++ b/src/APNS.js @@ -260,5 +260,5 @@ if (process.env.TESTING) { APNS.chooseConns = chooseConns; APNS.handleTransmissionError = handleTransmissionError; } -module.exports = APNS; + export default APNS; diff --git a/src/GCM.js b/src/GCM.js index 3aa2520c..f094a461 100644 --- a/src/GCM.js +++ b/src/GCM.js @@ -173,5 +173,4 @@ if (process.env.TESTING) { GCM.sliceDevices = sliceDevices; } -module.exports = GCM; export default GCM; diff --git a/src/ParsePushAdapter.js b/src/ParsePushAdapter.js index e7a127af..523de595 100644 --- a/src/ParsePushAdapter.js +++ b/src/ParsePushAdapter.js @@ -77,4 +77,3 @@ export class ParsePushAdapter { } } export default ParsePushAdapter; -module.exports = ParsePushAdapter; From 42b2e0a7964ac328e6e5d1ce184b62006c04d981 Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Sun, 19 Mar 2017 10:57:10 -0400 Subject: [PATCH 2/5] nits --- .nvmrc | 2 ++ src/APNS.js | 4 +--- src/GCM.js | 4 +--- src/ParsePushAdapter.js | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..49164e77 --- /dev/null +++ b/.nvmrc @@ -0,0 +1,2 @@ +4.6 + diff --git a/src/APNS.js b/src/APNS.js index 37708b77..eb42dbec 100644 --- a/src/APNS.js +++ b/src/APNS.js @@ -19,7 +19,7 @@ const LOG_PREFIX = 'parse-server-push-adapter APNS'; * @param {String} args.bundleId The bundleId for cert * @param {Boolean} args.production Specifies which environment to connect to: Production (if true) or Sandbox */ -function APNS(args) { +export default function APNS(args) { // typePushConfig can be an array. let apnsArgsList = []; if (Array.isArray(args)) { @@ -260,5 +260,3 @@ if (process.env.TESTING) { APNS.chooseConns = chooseConns; APNS.handleTransmissionError = handleTransmissionError; } - -export default APNS; diff --git a/src/GCM.js b/src/GCM.js index f094a461..45770dee 100644 --- a/src/GCM.js +++ b/src/GCM.js @@ -9,7 +9,7 @@ const LOG_PREFIX = 'parse-server-push-adapter GCM'; const GCMTimeToLiveMax = 4 * 7 * 24 * 60 * 60; // GCM allows a max of 4 weeks const GCMRegistrationTokensMax = 1000; -function GCM(args) { +export default function GCM(args) { if (typeof args !== 'object' || !args.apiKey) { throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED, 'GCM Configuration is invalid'); @@ -172,5 +172,3 @@ GCM.generateGCMPayload = generateGCMPayload; if (process.env.TESTING) { GCM.sliceDevices = sliceDevices; } - -export default GCM; diff --git a/src/ParsePushAdapter.js b/src/ParsePushAdapter.js index 523de595..af60be1e 100644 --- a/src/ParsePushAdapter.js +++ b/src/ParsePushAdapter.js @@ -7,7 +7,7 @@ import { classifyInstallations } from './PushAdapterUtils'; const LOG_PREFIX = 'parse-server-push-adapter'; -export class ParsePushAdapter { +export default class ParsePushAdapter { supportsPushTracking = true; @@ -76,4 +76,3 @@ export class ParsePushAdapter { }) } } -export default ParsePushAdapter; From cdb5653f440b18f94808d1ab51527b432c7e5724 Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Sun, 19 Mar 2017 11:13:34 -0400 Subject: [PATCH 3/5] bumps codecov --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c455f2c..d9855d3f 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "babel-core": "^6.22.0", "babel-preset-es2015": "^6.6.0", "babel-preset-stage-0": "^6.22.0", - "codecov": "^1.0.1", + "codecov": "2.1.0", "istanbul": "1.1.0-alpha.1", "jasmine": "2.5.3", "jasmine-spec-reporter": "^3.2.0" From 0fa4337f44355005c106f3a2c04e8714b62adc68 Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Sun, 19 Mar 2017 11:49:03 -0400 Subject: [PATCH 4/5] bumps babel deps --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d9855d3f..1ab5b111 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,9 @@ "author": "Parse", "license": "MIT", "devDependencies": { - "babel-cli": "^6.23.0", - "babel-core": "^6.22.0", - "babel-preset-es2015": "^6.6.0", + "babel-cli": "^6.24.0", + "babel-core": "^6.24.0", + "babel-preset-es2015": "^6.24.0", "babel-preset-stage-0": "^6.22.0", "codecov": "2.1.0", "istanbul": "1.1.0-alpha.1", From 06fc9e8d587519b59d98c0984239dc99d4d7bda6 Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Sun, 19 Mar 2017 12:55:23 -0400 Subject: [PATCH 5/5] Use nyc (#71) --- .gitignore | 2 ++ .istanbul.yml | 2 -- .nycrc | 10 ++++++++++ package.json | 6 +++--- 4 files changed, 15 insertions(+), 5 deletions(-) delete mode 100644 .istanbul.yml create mode 100644 .nycrc diff --git a/.gitignore b/.gitignore index d6a29f41..cf52aaac 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ lib-cov coverage lib +.nyc_output + # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt diff --git a/.istanbul.yml b/.istanbul.yml deleted file mode 100644 index c0890a3f..00000000 --- a/.istanbul.yml +++ /dev/null @@ -1,2 +0,0 @@ -instrumentation: - excludes: ["**/spec/**"] diff --git a/.nycrc b/.nycrc new file mode 100644 index 00000000..10cbbdf4 --- /dev/null +++ b/.nycrc @@ -0,0 +1,10 @@ +{ + "reporter": [ + "lcov", + "text-summary" + ], + "exclude": [ + "**/spec/**", + "lib/" + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 1ab5b111..11f17375 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ ], "scripts": { "build": "./node_modules/.bin/babel src/ -d lib/", - "test": "TESTING=1 ./node_modules/.bin/istanbul cover ./node_modules/.bin/jasmine", + "test": "TESTING=1 nyc ./node_modules/.bin/jasmine", "prepublish": "npm run build" }, "keywords": [ @@ -28,9 +28,9 @@ "babel-preset-es2015": "^6.24.0", "babel-preset-stage-0": "^6.22.0", "codecov": "2.1.0", - "istanbul": "1.1.0-alpha.1", "jasmine": "2.5.3", - "jasmine-spec-reporter": "^3.2.0" + "jasmine-spec-reporter": "^3.2.0", + "nyc": "^10.1.2" }, "dependencies": { "apn": "^1.7.8",