diff --git a/.babelrc b/.babelrc index 1adf51874a..d2c5124745 100644 --- a/.babelrc +++ b/.babelrc @@ -20,7 +20,7 @@ }, "test": { "plugins": [ - ["webpack-loaders", { "config": "webpack.config.test.js", "verbose": true }], + ["webpack-loaders", { "config": "webpack.config.test.js", "verbose": false }], "babel-plugin-rewire", ["transform-define", { "__TEST__": "true" diff --git a/app/actions/async.js b/app/actions/async.js index 55b2276809..045c2fca49 100644 --- a/app/actions/async.js +++ b/app/actions/async.js @@ -60,7 +60,7 @@ export function doAppInit(opts, servicesToInit) { const { api, carelink, device, localStore, log } = services; dispatch(syncActions.initRequest()); - dispatch(syncActions.hideUnavailableDevices(hostMap[os.platform()])); + dispatch(syncActions.hideUnavailableDevices(opts.os || hostMap[os.platform()])); log('Initializing local store.'); localStore.init(localStore.getInitialState(), function(localStoreResult){ diff --git a/package.json b/package.json index 89ed3d7d5f..d4008b2143 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "build-docs": "./scripts/update-gh-pages.sh", "serve-docs": "./node_modules/.bin/gitbook serve", "test": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 mocha --retries 2 --compilers js:babel-register --recursive --require ./test/setup.js test/**/*.js", + "test-debug": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 mocha --retries 2 --compilers js:babel-register --recursive --require ./test/setup.js test/**/*.js --inspect --debug-brk", "test-all": "npm run lint && npm run test && npm run build", "test-watch": "npm test -- --watch", "test-e2e": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 mocha --retries 2 --compilers js:babel-register --require ./test/setup.js ./test/e2e.js", diff --git a/test/actions/async.test.js b/test/actions/async.test.js index 810af1f99d..a141fb42da 100644 --- a/test/actions/async.test.js +++ b/test/actions/async.test.js @@ -122,6 +122,13 @@ describe('Asynchronous Actions', () => { payload: {url: 'http://www.acme.com/patients/new'}, meta: {source: actionSources[actionTypes.SET_NEW_PATIENT_URL]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/login' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.LOGIN}, @@ -235,6 +242,13 @@ describe('Asynchronous Actions', () => { type: actionTypes.RETRIEVING_USERS_TARGETS, meta: {source: actionSources[actionTypes.RETRIEVING_USERS_TARGETS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -342,6 +356,13 @@ describe('Asynchronous Actions', () => { type: actionTypes.RETRIEVING_USERS_TARGETS, meta: {source: actionSources[actionTypes.RETRIEVING_USERS_TARGETS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -435,6 +456,13 @@ describe('Asynchronous Actions', () => { metric: {eventName: metrics.LOGIN_SUCCESS} } }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/no_upload_targets' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.NO_UPLOAD_TARGETS}, @@ -493,6 +521,13 @@ describe('Asynchronous Actions', () => { metric: {eventName: metrics.CLINIC_LOGIN_SUCCESS} } }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/clinic_user_select' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.CLINIC_USER_SELECT}, @@ -536,6 +571,13 @@ describe('Asynchronous Actions', () => { type: actionTypes.LOGOUT_SUCCESS, meta: {source: actionSources[actionTypes.LOGOUT_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/login' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.LOGIN}, @@ -572,6 +614,13 @@ describe('Asynchronous Actions', () => { payload: new Error(getLogoutErrorMessage()), meta: {source: actionSources[actionTypes.LOGOUT_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/login' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.LOGIN}, @@ -1783,6 +1832,13 @@ describe('Asynchronous Actions', () => { payload: {userId: 'abc123', profile: profile}, meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.MAIN}, @@ -1842,6 +1898,13 @@ describe('Asynchronous Actions', () => { payload: {userId: 'abc123', profile: profile}, meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.MAIN}, @@ -1906,6 +1969,13 @@ describe('Asynchronous Actions', () => { payload: err, error: true }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.MAIN}, @@ -1965,6 +2035,13 @@ describe('Asynchronous Actions', () => { payload: {userId: 'abc123', profile: profile}, meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.MAIN}, @@ -2023,6 +2100,13 @@ describe('Asynchronous Actions', () => { payload: {userId: 'def456', profile: {}}, meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.MAIN}, @@ -2088,6 +2172,13 @@ describe('Asynchronous Actions', () => { payload: {userId: 'def456', profile: {}}, meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -2176,6 +2267,13 @@ describe('Asynchronous Actions', () => { payload: {userId: 'def456', profile}, meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -2386,6 +2484,13 @@ describe('Asynchronous Actions', () => { type: actionTypes.RETRIEVING_USERS_TARGETS, meta: {source: actionSources[actionTypes.RETRIEVING_USERS_TARGETS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -2412,6 +2517,13 @@ describe('Asynchronous Actions', () => { type: actionTypes.RETRIEVING_USERS_TARGETS, meta: {source: actionSources[actionTypes.RETRIEVING_USERS_TARGETS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -2460,6 +2572,13 @@ describe('Asynchronous Actions', () => { payload: { devicesByUser }, meta: {source: actionSources[actionTypes.SET_UPLOADS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -2512,6 +2631,13 @@ describe('Asynchronous Actions', () => { payload: { devicesByUser }, meta: {source: actionSources[actionTypes.SET_UPLOADS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.MAIN}, @@ -2576,6 +2702,13 @@ describe('Asynchronous Actions', () => { payload: { targets }, meta: {source: actionSources[actionTypes.SET_USERS_TARGETS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -2641,6 +2774,13 @@ describe('Asynchronous Actions', () => { payload: {userId: 'abc123', profile: profile}, meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]}, }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: { page: pages.MAIN }, @@ -2728,6 +2868,13 @@ describe('Asynchronous Actions', () => { payload: {userId: 'abc123', profile: profile}, meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: { page: pages.MAIN }, @@ -2806,6 +2953,13 @@ describe('Asynchronous Actions', () => { payload: { targets }, meta: {source: actionSources[actionTypes.SET_USERS_TARGETS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -2878,6 +3032,13 @@ describe('Asynchronous Actions', () => { payload: {userId: 'abc123', profile: profile}, meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.MAIN}, @@ -2962,6 +3123,13 @@ describe('Asynchronous Actions', () => { payload: {userId: 'abc123', profile: profile}, meta: {source: actionSources[actionTypes.UPDATE_PROFILE_SUCCESS]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.MAIN}, @@ -3037,6 +3205,13 @@ describe('Asynchronous Actions', () => { payload: { userId: newUser.userid }, meta: {source: actionSources[actionTypes.SET_UPLOAD_TARGET_USER]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -3147,6 +3322,13 @@ describe('Asynchronous Actions', () => { payload: { url }, meta: {source: actionSources[actionTypes.SET_BLIP_VIEW_DATA_URL]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -3218,6 +3400,13 @@ describe('Asynchronous Actions', () => { describe('target user has selected devices', () => { it('should dispatch SET_PAGE (main)', () => { const expectedActions = [ + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/main' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.MAIN}, @@ -3259,6 +3448,13 @@ describe('Asynchronous Actions', () => { describe('target user has not selected devices', () => { it('should dispatch SET_PAGE (settings)', () => { const expectedActions = [ + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/settings' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.SETTINGS}, @@ -3339,6 +3535,13 @@ describe('Asynchronous Actions', () => { payload: { userId: null }, meta: {source: actionSources[actionTypes.SET_UPLOAD_TARGET_USER]} }, + { + type: '@@router/CALL_HISTORY_METHOD', + payload: { + args: [ '/clinic_user_edit' ], + method: 'push' + } + }, { type: actionTypes.SET_PAGE, payload: {page: pages.CLINIC_USER_EDIT}, diff --git a/test/browser/testTimezoneOffsetUtil.js b/test/browser/testTimezoneOffsetUtil.js index a0ba23be70..d4d18e6e1f 100644 --- a/test/browser/testTimezoneOffsetUtil.js +++ b/test/browser/testTimezoneOffsetUtil.js @@ -19,6 +19,7 @@ var _ = require('lodash'); var d3 = require('d3'); +var sinon = require('sinon'); var expect = require('chai').expect; var builder = require('../../lib/objectBuilder')(); diff --git a/test/node/testLocalStore.js b/test/node/testLocalStore.js index e888ad4da9..0316d1253f 100644 --- a/test/node/testLocalStore.js +++ b/test/node/testLocalStore.js @@ -1,29 +1,34 @@ /* * == BSD2 LICENSE == * Copyright (c) 2014, Tidepool Project - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the associated License, which is identical to the BSD 2-Clause * License as published by the Open Source Initiative at opensource.org. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the License for more details. - * + * * You should have received a copy of the License along with this program; if * not, you can obtain one from Tidepool Project at tidepool.org. * == BSD2 LICENSE == */ -/*eslint-env mocha*/ +/*eslint-env mocha + +The entirety of our localstore wrapper needs to be re-thought in electron, +commenting this out for now to reduce noise var _ = require('lodash'); -var expect = require('salinity').expect; +var expect = require('chai').expect; var localStore = require('../../lib/core/localStore'); +console.log('testlocalStore: ', localStore); describe('localStore [node.js version for testing]', function() { it('is an object', function() { + console.log('in it:',localStore, typeof localStore); expect(typeof localStore).equals('object'); }); @@ -50,7 +55,10 @@ describe('localStore [node.js version for testing]', function() { describe('localStore.getItem', function() { var data = {blocks: {mine: ['a', 'b'], yours: [1,2,3]}}; - localStore = localStore(data); + + before(function(){ + localStore.init(data, console.log); + }); it('is a function', function() { expect(localStore.getItem).to.exist; @@ -58,7 +66,11 @@ describe('localStore [node.js version for testing]', function() { }); it('retrieves an item from the store', function() { - expect(localStore.getItem('blocks')).deep.equals(data.blocks); + console.log('inretrieve: ',localStore, localStore.getItem); + var intLocalStore = localStore; + var getItem = localStore.getItem; + debugger; + expect(localStore.getItem('blocks', console.log)).deep.equals(data.blocks); }); }); @@ -78,4 +90,5 @@ describe('localStore [node.js version for testing]', function() { expect(localStore.getItem('foo')).equals('blocks'); }); }); -}); \ No newline at end of file +}); +*/