Skip to content

Commit

Permalink
Merge pull request #1 from InspireNL/add-dev-dependencies-and-tests
Browse files Browse the repository at this point in the history
Add dev dependencies and tests
  • Loading branch information
florisvlasveld authored Jan 24, 2018
2 parents 0d367f7 + 1f5bf65 commit 1de44a0
Show file tree
Hide file tree
Showing 6 changed files with 3,730 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
9 changes: 9 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "airbnb",
"plugins": ["jest"],
"parser": "babel-eslint",
"rules": {
"semi": [2, "never"],
"arrow-body-style": [0, "as-needed"]
}
}
18 changes: 15 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
{
"name": "redux-offline-queue",
"version": "1.0.0",
"description": "Simple offline queue for redux, inspire by redux-queue-offline.",
"description": "Simple offline queue for redux, inspired by redux-queue-offline.",
"main": "./src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"keywords": [
"redux",
"offline",
"queue"
],
"author": "",
"license": "ISC",
"license": "MIT",
"dependencies": {
"lodash": "^4.17.4",
"redux-persist": "^5.5.0",
"reduxsauce": "^0.7.0"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.1",
"babel-jest": "^22.1.0",
"babel-preset-es2015": "^6.24.1",
"eslint": "^4.16.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.5.1",
"jest": "^22.1.4"
}
}
2 changes: 1 addition & 1 deletion src/reducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { REHYDRATE } from 'redux-persist/constants'
import { REHYDRATE } from 'redux-persist'

import INITIAL_STATE from './initialState'
import { QUEUE_ACTION, ONLINE, OFFLINE, RESET_QUEUE } from './actions'
Expand Down
34 changes: 34 additions & 0 deletions tests/offlineActions.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { createOfflineActions, markActionsOffline } from '../src/offlineActions'

test('createOfflineActions returns enchanced actions with offline meta keys', () => {
const { Creators } = createOfflineActions({
test: ['testId'],
})

expect(Creators.test(1)).toEqual({
type: 'TEST',
testId: 1,
meta: {
queueIfOffline: true,
},
})
})

test('markActionsOffline modifies Creators object', () => {
const Creators = {
test: testId => ({
type: 'TEST',
testId,
}),
}

markActionsOffline(Creators, ['test'])

expect(Creators.test(1)).toEqual({
type: 'TEST',
testId: 1,
meta: {
queueIfOffline: true,
},
})
})
Loading

0 comments on commit 1de44a0

Please sign in to comment.