diff --git a/.gitignore b/.gitignore index d6a29f4..cf52aaa 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 c0890a3..0000000 --- a/.istanbul.yml +++ /dev/null @@ -1,2 +0,0 @@ -instrumentation: - excludes: ["**/spec/**"] diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..49164e7 --- /dev/null +++ b/.nvmrc @@ -0,0 +1,2 @@ +4.6 + diff --git a/.nycrc b/.nycrc new file mode 100644 index 0000000..10cbbdf --- /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 0c455f2c..11f1737 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": [ @@ -23,14 +23,14 @@ "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": "^1.0.1", - "istanbul": "1.1.0-alpha.1", + "codecov": "2.1.0", "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", diff --git a/spec/APNS.spec.js b/spec/APNS.spec.js index 98f346b..c2da41a 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 7f53f29..2414ed7 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 da3cf87..5b8e0fb 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 d76ff02..eb42dbe 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; } -module.exports = APNS; -export default APNS; diff --git a/src/GCM.js b/src/GCM.js index 3aa2520..45770de 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,6 +172,3 @@ GCM.generateGCMPayload = generateGCMPayload; if (process.env.TESTING) { GCM.sliceDevices = sliceDevices; } - -module.exports = GCM; -export default GCM; diff --git a/src/ParsePushAdapter.js b/src/ParsePushAdapter.js index e7a127a..af60be1 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,5 +76,3 @@ export class ParsePushAdapter { }) } } -export default ParsePushAdapter; -module.exports = ParsePushAdapter;