From 1a13c108a870dd6941f468946a563c4f48121cb3 Mon Sep 17 00:00:00 2001 From: Lidan Hifi Date: Sat, 9 Apr 2016 11:41:28 +0300 Subject: [PATCH] add mocha for testing, eslint --- .eslintrc | 36 ++++++++++++++++++++++++++++++++++ .npmignore | 1 + README.md | 2 ++ index.ios.js | 40 +++++++++++++++++++------------------- package.json | 44 ++++++++++++++++++++++++++++-------------- test/index.ios.spec.js | 7 +++++++ 6 files changed, 96 insertions(+), 34 deletions(-) create mode 100644 .eslintrc create mode 100644 test/index.ios.spec.js diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..f2a7a0a --- /dev/null +++ b/.eslintrc @@ -0,0 +1,36 @@ +{ + "parser": "babel-eslint", + "env": { + "node": true, + "mocha": true, + "es6": true + }, + "extends": "eslint:recommended", + "rules": { + "indent": [ + "error", + 2 + ], + "linebreak-style": [ + "error", + "unix" + ], + "no-trailing-spaces": "error", + "quotes": [ + "error", + "double" + ], + "semi": [ + "error", + "always" + ], + "camelcase": [ + "error", + {"properties": "always"} + ], + "eqeqeq": [ + "error", + "smart" + ] + } +} diff --git a/.npmignore b/.npmignore index 90c978b..ffa2e1f 100644 --- a/.npmignore +++ b/.npmignore @@ -1 +1,2 @@ example/ +test/ diff --git a/README.md b/README.md index f7722b9..ebc7660 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # React Native Notifications +Handle push notifications for your app, including permission handling and icon badge number. + In progress diff --git a/index.ios.js b/index.ios.js index 7c92e3e..ded6b6f 100644 --- a/index.ios.js +++ b/index.ios.js @@ -2,14 +2,14 @@ * @providesModule RNNotifications * @flow */ -'use strict'; -import { NativeModules, DeviceEventEmitter } from 'react-native'; -import Map from 'core-js/library/es6/map'; -var NativeRNNotifications = NativeModules.RNNotifications; +"use strict"; +import { NativeModules, DeviceEventEmitter } from "react-native"; +import Map from "core-js/library/es6/map"; +var NativeRNNotifications = NativeModules.RNNotifications; // eslint-disable-line no-unused-vars -var DEVICE_NOTIFICATION_RECEIVED_FOREGROUND_EVENT = 'notificationReceivedForeground'; -var DEVICE_NOTIFICATION_RECEIVED_BACKGROUND_EVENT = 'notificationReceivedBackground'; -var DEVICE_NOTIFICATION_OPENED_EVENT = 'notificationOpened'; +var DEVICE_NOTIFICATION_RECEIVED_FOREGROUND_EVENT = "notificationReceivedForeground"; +var DEVICE_NOTIFICATION_RECEIVED_BACKGROUND_EVENT = "notificationReceivedBackground"; +var DEVICE_NOTIFICATION_OPENED_EVENT = "notificationOpened"; var _notificationHandlers = new Map(); @@ -28,14 +28,14 @@ class NotificationsIOS { if (type === DEVICE_NOTIFICATION_RECEIVED_FOREGROUND_EVENT || type === DEVICE_NOTIFICATION_RECEIVED_BACKGROUND_EVENT || type === DEVICE_NOTIFICATION_OPENED_EVENT) { - var listener = DeviceEventEmitter.addListener( - type, - (notification) => { - handler(notification); - } - ); + var listener = DeviceEventEmitter.addListener( + type, + (notification) => { + handler(notification); + } + ); - _notificationHandlers.set(handler, listener); + _notificationHandlers.set(handler, listener); } } @@ -47,13 +47,13 @@ class NotificationsIOS { if (type === DEVICE_NOTIFICATION_RECEIVED_FOREGROUND_EVENT || type === DEVICE_NOTIFICATION_RECEIVED_BACKGROUND_EVENT || type === DEVICE_NOTIFICATION_OPENED_EVENT) { - var listener = _notificationHandlers.get(handler); - if (!listener) { - return; - } + var listener = _notificationHandlers.get(handler); + if (!listener) { + return; + } - listener.remove(); - _notificationHandlers.delete(handler); + listener.remove(); + _notificationHandlers.delete(handler); } } } diff --git a/package.json b/package.json index c5d9ba1..6a449d4 100644 --- a/package.json +++ b/package.json @@ -1,32 +1,48 @@ { "name": "react-native-notifications", - "publishConfig": { - "registry": "https://registry.npmjs.org/" - }, - "repository": { - "type": "git", - "url": "https://github.com/wix/react-native-notifications.git" - }, "version": "0.0.5", "description": "Advanced Push Notifications (Silent, interactive notifications) for iOS & Android", + "author": "Lidan Hifi ", + "license": "MIT", "keywords": [ "react-component", "react-native", + "react native", "ios", - "push-notifications" + "push-notifications", + "notifications", + "notification", + "react native notifications" ], "nativePackage": true, + "dependencies": { + "core-js": "^1.0.0" + }, "peerDependencies": { "react-native": ">=0.19.0" }, + "devDependencies": { + "babel-eslint": "^6.0.2", + "chai": "^3.5.0", + "chokidar-cli": "^1.2.0", + "eslint": "^2.7.0", + "mocha": "^2.4.5" + }, + "scripts": { + "pretest": "./node_modules/.bin/eslint *.js test", + "test": "./node_modules/.bin/mocha --reporter spec \"test/*.spec.js\"", + "start": "npm run test --silent; ./node_modules/.bin/chokidar \"test/*.js\" \"*.js\" -c 'npm run test --silent' --silent" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org/" + }, + "repository": { + "type": "git", + "url": "https://github.com/wix/react-native-notifications.git" + }, "homepage": "https://github.com/wix/react-native-notifications", "bugs": { "url": "https://github.com/wix/react-native-notifications/issues" }, - "dependencies": { - "core-js": "^1.0.0" - }, - "author": "Lidan Hifi ", - "main": "index.ios.js", - "license": "MIT" + "main": "index.ios.js" } diff --git a/test/index.ios.spec.js b/test/index.ios.spec.js new file mode 100644 index 0000000..23386a0 --- /dev/null +++ b/test/index.ios.spec.js @@ -0,0 +1,7 @@ +var expect = require("chai").expect; + +describe("NotificationsIOS", function () { + it("should pass", function () { + expect(true).to.be.true; + }); +}); -- 2.26.2