diff --git a/.travis.yml b/.travis.yml index 313de2a..32a10de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,4 +27,4 @@ deploy: on: branch: master after_success: - - npm run test:coverage && bash <(curl -s https://codecov.io/bash) -e TRAVIS_NODE_VERSION \ No newline at end of file + - npm run test:coverage && codecov -t $CODECOV_TOKEN \ No newline at end of file diff --git a/README.md b/README.md index ed0fe15..d999b97 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,7 @@ console.log(dummy()); # TODO - +- dotenv - bundlesize - Prepack -- redux-observable -- Badges: ci, coverage, npm - https://greenkeeper.io/ \ No newline at end of file diff --git a/src/webapp/actions/actions.test.js b/src/webapp/actions/actions.test.js index 836d4bf..5e260d6 100644 --- a/src/webapp/actions/actions.test.js +++ b/src/webapp/actions/actions.test.js @@ -30,23 +30,28 @@ test('syncState', () => { }); }); -// test('connectStore', () => { -// const { connectStore } = Actions(central, TYPES); -// expect.assertions(6); +test('connectStore', () => { + const { connectStore } = Actions(central, TYPES); + expect.assertions(8); -// const promise = connectStore('mockName')(dispatch).then(() => { -// expect(central.connect).toBeCalled(); -// expect(central.handler).toBeCalled(); + const promise = connectStore('mockName')(dispatch).then(() => { + expect(central.connect).toBeCalled(); + expect(central.handler).toBeCalled(); -// expect(dispatch.mock.calls.length).toBe(2); -// expect(dispatch.mock.calls[0][0]).toEqual({ type: TYPES.BLUETOOTH_CONNECTING }); -// expect(dispatch.mock.calls[1][0]).toEqual({ type: TYPES.BLUETOOTH_CONNECTED }); + expect(dispatch.mock.calls.length).toBe(3); + expect(dispatch.mock.calls[0][0]).toEqual({ type: TYPES.BLUETOOTH_CONNECTING }); + expect(dispatch.mock.calls[1][0]).toEqual({ type: TYPES.BLUETOOTH_CONNECTED }); -// return true; -// }); + return dispatch.mock.calls[2][0](dispatch); // syncStore + }).then(() => { + expect(central.read).toBeCalled(); + expect(dispatch.mock.calls[3][0]).toEqual({ type: TYPES.BLUETOOTH_SYNC, payload: 'mockState' }); -// return expect(promise).resolves.toBe(true); -// }); + return true; + }); + + return expect(promise).resolves.toBe(true); +}); test('syncStore', () => { const { syncStore } = Actions(central, TYPES); diff --git a/src/webapp/reducers/index.js b/src/webapp/reducers/index.js index 4972eb7..1d2b085 100644 --- a/src/webapp/reducers/index.js +++ b/src/webapp/reducers/index.js @@ -1,9 +1,7 @@ import * as TYPES from '../actions/types'; import * as STATUS from '../central/status'; -const initial = { - status: STATUS.INIT, -}; +import initial from './initial'; export default (autosync = true) => (state = initial, { type, payload }) => { switch (type) { diff --git a/src/webapp/reducers/index.test.js b/src/webapp/reducers/index.test.js new file mode 100644 index 0000000..dcf066c --- /dev/null +++ b/src/webapp/reducers/index.test.js @@ -0,0 +1,11 @@ +/* global jest, beforeEach, afterEach, test, expect */ +import Reducer from '.'; + +test('type: UNKNOWN', () => { + const reducer = Reducer(); + + const originalState = { }; + const nextState = reducer(originalState, { type: 'UNKNOWN' }); + + return expect(nextState).toBe(originalState); +}); diff --git a/src/webapp/reducers/initial.js b/src/webapp/reducers/initial.js new file mode 100644 index 0000000..e69de29