From 5c8c9aec73b7932773518260dfb020f8fb7493cc Mon Sep 17 00:00:00 2001 From: Chris McGee Date: Mon, 20 Feb 2017 15:32:18 -0500 Subject: [PATCH] test fixes --- .babelrc | 6 +- package.json | 5 +- test/actions/async.test.js | 132 +++++++++++++------------ test/actions/sync.test.js | 30 +++--- test/actions/utils.test.js | 8 +- test/browser/testTimezoneOffsetUtil.js | 12 +-- test/reducers/misc.test.js | 21 ++-- test/reducers/uploads.test.js | 13 +-- test/reducers/users.test.js | 11 ++- webpack.config.test.js | 2 +- 10 files changed, 127 insertions(+), 113 deletions(-) diff --git a/.babelrc b/.babelrc index 4e8db7d68b..1adf51874a 100644 --- a/.babelrc +++ b/.babelrc @@ -20,7 +20,11 @@ }, "test": { "plugins": [ - ["webpack-loaders", { "config": "webpack.config.test.js", "verbose": false }] + ["webpack-loaders", { "config": "webpack.config.test.js", "verbose": true }], + "babel-plugin-rewire", + ["transform-define", { + "__TEST__": "true" + }] ] } } diff --git a/package.json b/package.json index eee04e388a..89ed3d7d5f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "scripts": { "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/**/*.spec.js", + "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-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", @@ -107,9 +107,10 @@ "babel-loader": "6.2.10", "babel-plugin-add-module-exports": "0.2.1", "babel-plugin-dev-expression": "0.2.1", - "babel-plugin-rewire": "0.1.22", + "babel-plugin-rewire": "1.0.0", "babel-plugin-tcomb": "0.3.24", "babel-plugin-transform-class-properties": "6.22.0", + "babel-plugin-transform-define": "1.2.0", "babel-plugin-transform-es2015-classes": "6.22.0", "babel-plugin-webpack-loaders": "0.8.0", "babel-polyfill": "6.22.0", diff --git a/test/actions/async.test.js b/test/actions/async.test.js index 7fddc5ae0b..810af1f99d 100644 --- a/test/actions/async.test.js +++ b/test/actions/async.test.js @@ -21,19 +21,21 @@ import _ from 'lodash'; import { isFSA } from 'flux-standard-action'; import configureStore from 'redux-mock-store'; import thunk from 'redux-thunk'; +import { expect } from 'chai'; -import * as actionSources from '../../../../lib/redux/constants/actionSources'; -import * as actionTypes from '../../../../lib/redux/constants/actionTypes'; -import * as metrics from '../../../../lib/redux/constants/metrics'; -import { pages, steps, urls } from '../../../../lib/redux/constants/otherConstants'; -import { UnsupportedError } from '../../../../lib/redux/utils/errors'; -import errorText from '../../../../lib/redux/constants/errors'; +import * as actionSources from '../../app/constants/actionSources'; +import * as actionTypes from '../../app/constants/actionTypes'; +import * as metrics from '../../app/constants/metrics'; +import { pages, steps, urls } from '../../app/constants/otherConstants'; +import { UnsupportedError } from '../../app/utils/errors'; +import errorText from '../../app/constants/errors'; -import * as asyncActions from '../../../../lib/redux/actions/async'; -import { getLoginErrorMessage, getLogoutErrorMessage, getUpdateProfileErrorMessage, getCreateCustodialAccountErrorMessage } from '../../../../lib/redux/utils/errors'; +import * as asyncActions from '../../app/actions/async'; +import { __Rewire__, __ResetDependency__ } from '../../app/actions/async'; +import { getLoginErrorMessage, getLogoutErrorMessage, getUpdateProfileErrorMessage, getCreateCustodialAccountErrorMessage } from '../../app/utils/errors'; -let pwd = require('../../fixtures/pwd.json'); -let nonpwd = require('../../fixtures/nonpwd.json'); +let pwd = require('../browser/fixtures/pwd.json'); +let nonpwd = require('../browser/fixtures/nonpwd.json'); const middlewares = [thunk]; const mockStore = configureStore(middlewares); @@ -52,7 +54,7 @@ describe('Asynchronous Actions', () => { afterEach(function() { // very important to do this in an afterEach than in each test when __Rewire__ is used // if you try to reset within each test you'll make it impossible for tests to fail! - asyncActions.__ResetDependency__('services'); + __ResetDependency__('services'); }); describe('doAppInit [hot reload, app already initialized]', () => { @@ -138,7 +140,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.VERSION_CHECK_SUCCESS]} } ]; - asyncActions.__Rewire__('versionInfo', { + __Rewire__('versionInfo', { semver: config.version }); const store = mockStore({working: {initializingApp: true}}); @@ -239,7 +241,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('versionInfo', { + __Rewire__('versionInfo', { semver: config.version }); const state = { @@ -298,7 +300,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.INIT_APP_FAILURE]} } ]; - asyncActions.__Rewire__('versionInfo', { + __Rewire__('versionInfo', { semver: config.version }); const store = mockStore({working: {initializingApp: true}}); @@ -346,7 +348,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { loginExtended: (creds, opts, cb) => cb(null, [userObj, profile, memberships]) @@ -389,7 +391,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.LOGIN_FAILURE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { loginExtended: (creds, opts, cb) => cb(getLoginErrorMessage()) @@ -439,7 +441,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { loginExtended: (creds, opts, cb) => cb(null, [userObj, profile, memberships]) @@ -500,7 +502,7 @@ describe('Asynchronous Actions', () => { } } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { loginExtended: (creds, opts, cb) => cb(null, [userObj, profile, memberships]) @@ -540,7 +542,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources.USER} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { logout: (cb) => cb(null) @@ -576,7 +578,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources.USER} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { logout: (cb) => cb('Error :(') @@ -594,7 +596,7 @@ describe('Asynchronous Actions', () => { it('should dispatch VERSION_CHECK_REQUEST, VERSION_CHECK_FAILURE, UPLOAD_ABORTED', () => { const requiredVersion = '0.99.0'; const currentVersion = '0.50.0'; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => cb(null, {uploaderMinimum: requiredVersion}) @@ -625,7 +627,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.UPLOAD_ABORTED]} } ]; - asyncActions.__Rewire__('versionInfo', { + __Rewire__('versionInfo', { semver: currentVersion }); const store = mockStore({}); @@ -640,7 +642,7 @@ describe('Asynchronous Actions', () => { const initialState = { working: {uploading: true} }; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => cb(null, {uploaderMinimum: '0.99.0'}) @@ -663,7 +665,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.UPLOAD_ABORTED]} } ]; - asyncActions.__Rewire__('versionInfo', { + __Rewire__('versionInfo', { semver: '0.100.0' }); const store = mockStore(initialState); @@ -716,7 +718,7 @@ describe('Asynchronous Actions', () => { err.utc = errProps.utc; err.version = errProps.version; err.debug = `UTC Time: ${time} | Code: ${errProps.code} | Version: ${errProps.version}`; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => cb(null, {uploaderMinimum: '0.99.0'}) @@ -816,7 +818,7 @@ describe('Asynchronous Actions', () => { err.utc = errProps.utc; err.version = errProps.version; err.debug = `UTC Time: ${time} | Code: ${errProps.code} | Version: ${errProps.version}`; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => cb(null, {uploaderMinimum: '0.99.0'}) @@ -916,7 +918,7 @@ describe('Asynchronous Actions', () => { err.utc = errProps.utc; err.version = errProps.version; err.debug = `UTC Time: ${time} | Code: ${errProps.code} | Version: ${errProps.version}`; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => cb(null, {uploaderMinimum: '0.99.0'}) @@ -1019,7 +1021,7 @@ describe('Asynchronous Actions', () => { err.code = errProps.code; err.version = errProps.version; err.debug = `Details: ${basalErr} | UTC Time: ${time} | Name: Error | Code: ${errProps.code} | Version: ${errProps.version}`; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => cb(null, {uploaderMinimum: '0.99.0'}) @@ -1110,7 +1112,7 @@ describe('Asynchronous Actions', () => { version: '0.100.0', working: {uploading: false} }; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => cb(null, {uploaderMinimum: '0.99.0'}) @@ -1213,7 +1215,7 @@ describe('Asynchronous Actions', () => { err.code = errProps.code; err.version = errProps.version; err.debug = `Details: Error! | UTC Time: ${time} | Code: ${errProps.code} | Version: ${errProps.version}`; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { fetchCarelinkData: (foo, cb) => cb(new Error('Error!')), @@ -1321,7 +1323,7 @@ describe('Asynchronous Actions', () => { err.code = errProps.code; err.version = errProps.version; err.debug = `UTC Time: ${time} | Code: ${errProps.code} | Version: ${errProps.version}`; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { fetchCarelinkData: (foo, cb) => cb(null, '302 Moved Temporarily'), @@ -1432,7 +1434,7 @@ describe('Asynchronous Actions', () => { err.code = errProps.code; err.version = errProps.version; err.debug = `Details: ${basalErr} | UTC Time: ${time} | Name: Error | Code: ${errProps.code} | Version: ${errProps.version}`; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { fetchCarelinkData: (foo, cb) => cb(null, '1,2,3,4,5'), @@ -1532,7 +1534,7 @@ describe('Asynchronous Actions', () => { version: '0.100.0', working: {uploading: false} }; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { fetchCarelinkData: (foo, cb) => cb(null, '1,2,3,4,5'), @@ -1649,7 +1651,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.VERSION_CHECK_FAILURE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => { cb(err); } @@ -1678,7 +1680,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.VERSION_CHECK_FAILURE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => { cb(err); } @@ -1714,14 +1716,14 @@ describe('Asynchronous Actions', () => { } } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => { cb(null, {uploaderMinimum: requiredVersion}); } } } }); - asyncActions.__Rewire__('versionInfo', { + __Rewire__('versionInfo', { semver: currentVersion }); const store = mockStore({}); @@ -1744,14 +1746,14 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.VERSION_CHECK_SUCCESS]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { upload: { getVersions: (cb) => { cb(null, {uploaderMinimum: requiredVersion}); } } } }); - asyncActions.__Rewire__('versionInfo', { + __Rewire__('versionInfo', { semver: currentVersion }); const store = mockStore({}); @@ -1787,7 +1789,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -1846,7 +1848,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -1910,7 +1912,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -1969,7 +1971,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -2027,7 +2029,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { account: (cb) => cb(null, userObj.user), @@ -2092,7 +2094,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { account: (cb) => cb(null, userObj.user), @@ -2147,7 +2149,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.UPDATE_PROFILE_FAILURE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { updateProfile: (user, update, cb) => cb('error') @@ -2180,7 +2182,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { updateProfile: (user, update, cb) => cb({status:401}) @@ -2231,7 +2233,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_TARGET_TIMEZONE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -2281,7 +2283,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_TARGET_TIMEZONE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -2336,7 +2338,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_TARGET_TIMEZONE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -2390,7 +2392,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { localStore: { getItem: () => null, removeItem: (item) => null @@ -2416,7 +2418,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { localStore: { getItem: () => null, removeItem: (item) => null @@ -2464,7 +2466,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { makeBlipUrl: blipUrlMaker }, @@ -2516,7 +2518,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { makeBlipUrl: blipUrlMaker }, @@ -2580,7 +2582,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { localStore: { getItem: () => targets, removeItem: (item) => null @@ -2645,7 +2647,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -2732,7 +2734,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -2810,7 +2812,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { makeBlipUrl: blipUrlMaker }, @@ -2882,7 +2884,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -2966,7 +2968,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { profile: (cb) => { @@ -3041,7 +3043,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { account: (cb) => cb(null, userObj.user), @@ -3072,7 +3074,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.CREATE_CUSTODIAL_ACCOUNT_FAILURE]} } ]; - asyncActions.__Rewire__('services', { + __Rewire__('services', { api: { user: { createCustodialAccount: (profile, cb) => cb('error') @@ -3109,7 +3111,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_BLIP_VIEW_DATA_URL]} } ]; - asyncActions.__Rewire__('services', apiRewire); + __Rewire__('services', apiRewire); const store = mockStore({ devices: { a_pump: {} @@ -3151,7 +3153,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_PAGE]} } ]; - asyncActions.__Rewire__('services', apiRewire); + __Rewire__('services', apiRewire); const store = mockStore({ devices: { carelink: {}, @@ -3186,7 +3188,7 @@ describe('Asynchronous Actions', () => { meta: {source: actionSources[actionTypes.SET_BLIP_VIEW_DATA_URL]} } ]; - asyncActions.__Rewire__('services', apiRewire); + __Rewire__('services', apiRewire); const store = mockStore({ devices: { carelink: {}, diff --git a/test/actions/sync.test.js b/test/actions/sync.test.js index 63e030a719..cf86dbce18 100644 --- a/test/actions/sync.test.js +++ b/test/actions/sync.test.js @@ -1,15 +1,15 @@ /* * == 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 == @@ -19,15 +19,17 @@ import _ from 'lodash'; import { isFSA } from 'flux-standard-action'; +import { expect } from 'chai'; -import * as actionSources from '../../../../lib/redux/constants/actionSources'; -import * as actionTypes from '../../../../lib/redux/constants/actionTypes'; -import * as metrics from '../../../../lib/redux/constants/metrics'; -import { steps } from '../../../../lib/redux/constants/otherConstants'; +import * as actionSources from '../../app/constants/actionSources'; +import * as actionTypes from '../../app/constants/actionTypes'; +import * as metrics from '../../app/constants/metrics'; +import { steps } from '../../app/constants/otherConstants'; -import * as syncActions from '../../../../lib/redux/actions/sync'; -import { UnsupportedError } from '../../../../lib/redux/utils/errors'; -import errorText from '../../../../lib/redux/constants/errors'; +import * as syncActions from '../../app/actions/sync'; +import { __Rewire__, __ResetDependency__ } from '../../app/actions/sync'; +import { UnsupportedError } from '../../app/utils/errors'; +import errorText from '../../app/constants/errors'; describe('Synchronous Actions', () => { describe('addTargetDevice', () => { @@ -541,7 +543,7 @@ describe('Synchronous Actions', () => { }); it('should create an action to report a login error', () => { - syncActions.__Rewire__('getLoginErrorMessage', () => err); + __Rewire__('getLoginErrorMessage', () => err); const expectedAction = { type: actionTypes.LOGIN_FAILURE, error: true, @@ -549,7 +551,7 @@ describe('Synchronous Actions', () => { meta: {source: actionSources[actionTypes.LOGIN_FAILURE]} }; expect(syncActions.loginFailure(err)).to.deep.equal(expectedAction); - syncActions.__ResetDependency__('getLoginErrorMessage'); + __ResetDependency__('getLoginErrorMessage'); }); }); }); @@ -599,7 +601,7 @@ describe('Synchronous Actions', () => { }); it('should create an action to report a logout error', () => { - syncActions.__Rewire__('getLogoutErrorMessage', () => err); + __Rewire__('getLogoutErrorMessage', () => err); const expectedAction = { type: actionTypes.LOGOUT_FAILURE, error: true, @@ -607,7 +609,7 @@ describe('Synchronous Actions', () => { meta: {source: actionSources[actionTypes.LOGOUT_FAILURE]} }; expect(syncActions.logoutFailure(err)).to.deep.equal(expectedAction); - syncActions.__ResetDependency__('getLoginErrorMessage'); + __ResetDependency__('getLoginErrorMessage'); }); }); }); diff --git a/test/actions/utils.test.js b/test/actions/utils.test.js index d1561e891e..c4bf7cd803 100644 --- a/test/actions/utils.test.js +++ b/test/actions/utils.test.js @@ -18,12 +18,14 @@ /*eslint-env mocha*/ import _ from 'lodash'; +import sinon from 'sinon'; +import { expect } from 'chai'; import configureStore from 'redux-mock-store'; -import errorText from '../../../../lib/redux/constants/errors'; -import * as utils from '../../../../lib/redux/actions/utils'; -import { addInfoToError } from '../../../../lib/redux/utils/errors'; +import errorText from '../../app/constants/errors'; +import * as utils from '../../app/actions/utils'; +import { addInfoToError } from '../../app/utils/errors'; describe('utils', () => { describe('makeUploadCb', () => { diff --git a/test/browser/testTimezoneOffsetUtil.js b/test/browser/testTimezoneOffsetUtil.js index abaddafe6a..a0ba23be70 100644 --- a/test/browser/testTimezoneOffsetUtil.js +++ b/test/browser/testTimezoneOffsetUtil.js @@ -1,15 +1,15 @@ /* * == 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 == @@ -19,7 +19,7 @@ var _ = require('lodash'); var d3 = require('d3'); -var expect = chai.expect; +var expect = require('chai').expect; var builder = require('../../lib/objectBuilder')(); var TZOUtil = require('../../lib/TimezoneOffsetUtil'); @@ -622,7 +622,7 @@ describe('TimezoneOffsetUtil in practice', function(){ expect(offsets.length).to.equal(2); expect(offsets).to.deep.equal([-420, -360]); }); - + it('applies the offsets inferred from `changes`, resulting in no gaps or overlaps', function(done){ this.timeout(5000); setTimeout(function() { @@ -688,4 +688,4 @@ describe('TimezoneOffsetUtil in practice', function(){ done(); }, 50); }); -}); \ No newline at end of file +}); diff --git a/test/reducers/misc.test.js b/test/reducers/misc.test.js index eccd227d18..de77cd4e76 100644 --- a/test/reducers/misc.test.js +++ b/test/reducers/misc.test.js @@ -1,15 +1,15 @@ /* * == BSD2 LICENSE == * Copyright (c) 2015-2016, 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 == @@ -19,17 +19,18 @@ import _ from 'lodash'; import mutationTracker from 'object-invariant-test-helper'; +import { expect } from 'chai'; -import * as actionTypes from '../../../../lib/redux/constants/actionTypes'; -import { pages, steps } from '../../../../lib/redux/constants/otherConstants'; -import * as misc from '../../../../lib/redux/reducers/misc'; +import * as actionTypes from '../../app/constants/actionTypes'; +import { pages, steps } from '../../app/constants/otherConstants'; +import * as misc from '../../app/reducers/misc'; -import devices from '../../../../lib/redux/reducers/devices'; +import devices from '../../app/reducers/devices'; -import { UnsupportedError } from '../../../../lib/redux/utils/errors'; +import { UnsupportedError } from '../../app/utils/errors'; -let pwd = require('../../fixtures/pwd.json'); -let nonpwd = require('../../fixtures/nonpwd.json'); +let pwd = require('../browser/fixtures/pwd.json'); +let nonpwd = require('../browser/fixtures/nonpwd.json'); describe('misc reducers', () => { describe('devices', () => { diff --git a/test/reducers/uploads.test.js b/test/reducers/uploads.test.js index dc9e037a43..343977af45 100644 --- a/test/reducers/uploads.test.js +++ b/test/reducers/uploads.test.js @@ -1,15 +1,15 @@ /* * == BSD2 LICENSE == * Copyright (c) 2016, 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 == @@ -18,10 +18,11 @@ /*eslint-env mocha*/ import _ from 'lodash'; +import { expect } from 'chai'; -import * as actionTypes from '../../../../lib/redux/constants/actionTypes'; -import { steps } from '../../../../lib/redux/constants/otherConstants'; -import * as uploads from '../../../../lib/redux/reducers/uploads'; +import * as actionTypes from '../../app/constants/actionTypes'; +import { steps } from '../../app/constants/otherConstants'; +import * as uploads from '../../app/reducers/uploads'; describe('uploads', () => { describe('uploadProgress', () => { diff --git a/test/reducers/users.test.js b/test/reducers/users.test.js index c265dec1b1..07d4307214 100644 --- a/test/reducers/users.test.js +++ b/test/reducers/users.test.js @@ -1,15 +1,15 @@ /* * == BSD2 LICENSE == * Copyright (c) 2016, 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 == @@ -19,9 +19,10 @@ import _ from 'lodash'; import mutationTracker from 'object-invariant-test-helper'; +import { expect } from 'chai'; -import * as actionTypes from '../../../../lib/redux/constants/actionTypes'; -import * as users from '../../../../lib/redux/reducers/users'; +import * as actionTypes from '../../app/constants/actionTypes'; +import * as users from '../../app/reducers/users'; describe('users', () => { describe('allUsers', () => { diff --git a/webpack.config.test.js b/webpack.config.test.js index 8ad4597777..ab3309ce19 100755 --- a/webpack.config.test.js +++ b/webpack.config.test.js @@ -11,6 +11,6 @@ module.exports = validate({ }, module: { // Use base + development loaders, but exclude 'babel-loader' - loaders: devConfig.module.loaders.slice(1) + loaders: devConfig.default.module.loaders.slice(1) } });