diff --git a/.travis.yml b/.travis.yml index 75bb68a..38cdc83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,5 +27,4 @@ install: - npm install script: - - node -v - npm run test-react \ No newline at end of file diff --git a/package.json b/package.json index 8c2a9b8..3909351 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "react-dom": "^15.5.4", "react-redux": "^5.0.4", "redux": "^3.6.0", - "redux-api-middleware": "^1.0.3", + "redux-api-middleware": "^2.0.0-beta.2", "rimraf": "~2.6.1", "semver": "~5.3.0", "serve-static": "~1.12.2", @@ -152,7 +152,7 @@ "/config/localStorageMock.js" ], "testPathIgnorePatterns": [ - "[/\\\\](build|docs|node_modules|scripts|clicktests)[/\\\\]" + "[/\\\\](build|docs|node_modules|scripts|clicktests|src-react/__tests__/utils)[/\\\\]" ], "testEnvironment": "node", "testURL": "http://localhost", diff --git a/src-react/__tests__/actions/ungit-config.test.js b/src-react/__tests__/actions/ungit-config.test.js index db24256..f1ece64 100644 --- a/src-react/__tests__/actions/ungit-config.test.js +++ b/src-react/__tests__/actions/ungit-config.test.js @@ -1,4 +1,4 @@ -import { CALL_API } from 'redux-api-middleware'; +import { RSAA } from 'redux-api-middleware'; import expect from 'expect.js'; import * as types from 'constants/action-types'; @@ -6,17 +6,17 @@ import { fetchUngitConfig } from 'actions/ungit-config'; describe('ungit-config.js action', () => { describe('fetchUngitConfig', () => { - it('returns CALL_API action object', function(){ + it('returns RSAA action object', function(){ const action = fetchUngitConfig(); - expect(action[CALL_API]).to.be.an('object'); - expect(action[CALL_API].endpoint).to.eql('http://localhost:8448/ungit/config'); - expect(action[CALL_API].method).to.eql('GET'); - expect(action[CALL_API].types).to.be.an('array'); - expect(action[CALL_API].types[0]).to.eql(types.FETCH_UNGIT_CONFIG_REQUEST); - expect(action[CALL_API].types[1]).to.be.an('object'); - expect(action[CALL_API].types[1].type).to.eql(types.FETCH_UNGIT_CONFIG_SUCCESS); - expect(action[CALL_API].types[2]).to.eql(types.FETCH_UNGIT_CONFIG_FAILURE); + expect(action[RSAA]).to.be.an('object'); + expect(action[RSAA].endpoint).to.eql('http://localhost:8448/ungit/config'); + expect(action[RSAA].method).to.eql('GET'); + expect(action[RSAA].types).to.be.an('array'); + expect(action[RSAA].types[0]).to.eql(types.FETCH_UNGIT_CONFIG_REQUEST); + expect(action[RSAA].types[1]).to.be.an('object'); + expect(action[RSAA].types[1].type).to.eql(types.FETCH_UNGIT_CONFIG_SUCCESS); + expect(action[RSAA].types[2]).to.eql(types.FETCH_UNGIT_CONFIG_FAILURE); }); }); }); \ No newline at end of file diff --git a/src-react/__tests__/actions/user-config.test.js b/src-react/__tests__/actions/user-config.test.js index 60d25bb..edbd7fc 100644 --- a/src-react/__tests__/actions/user-config.test.js +++ b/src-react/__tests__/actions/user-config.test.js @@ -1,4 +1,4 @@ -import { CALL_API } from 'redux-api-middleware'; +import { RSAA } from 'redux-api-middleware'; import expect from 'expect.js'; import * as types from 'constants/action-types'; @@ -6,16 +6,16 @@ import { fetchUserConfig } from 'actions/user-config'; describe('user-config.js action', () => { describe('fetchUserConfig', () => { - it('returns CALL_API action object', function(){ + it('returns RSAA action object', function(){ const action = fetchUserConfig(); - expect(action[CALL_API]).to.be.an('object'); - expect(action[CALL_API].endpoint).to.eql('http://localhost:8448/api/userconfig'); - expect(action[CALL_API].method).to.eql('GET'); - expect(action[CALL_API].types).to.be.an('array'); - expect(action[CALL_API].types[0]).to.eql(types.FETCH_USER_CONFIG_REQUEST); - expect(action[CALL_API].types[1]).to.eql(types.FETCH_USER_CONFIG_SUCCESS); - expect(action[CALL_API].types[2]).to.eql(types.FETCH_USER_CONFIG_FAILURE); + expect(action[RSAA]).to.be.an('object'); + expect(action[RSAA].endpoint).to.eql('http://localhost:8448/api/userconfig'); + expect(action[RSAA].method).to.eql('GET'); + expect(action[RSAA].types).to.be.an('array'); + expect(action[RSAA].types[0]).to.eql(types.FETCH_USER_CONFIG_REQUEST); + expect(action[RSAA].types[1]).to.eql(types.FETCH_USER_CONFIG_SUCCESS); + expect(action[RSAA].types[2]).to.eql(types.FETCH_USER_CONFIG_FAILURE); }); }); }); \ No newline at end of file diff --git a/src-react/__tests__/actions/version.test.js b/src-react/__tests__/actions/version.test.js index a9ac579..6880cb6 100644 --- a/src-react/__tests__/actions/version.test.js +++ b/src-react/__tests__/actions/version.test.js @@ -1,4 +1,4 @@ -import { CALL_API } from 'redux-api-middleware'; +import { RSAA } from 'redux-api-middleware'; import expect from 'expect.js'; import * as types from 'constants/action-types'; @@ -6,30 +6,30 @@ import { fetchLatestVersion, fetchGitVersion } from 'actions/version'; describe('version.js action', () => { describe('fetchLatestVersion', () => { - it('returns CALL_API action object', function(){ + it('returns RSAA action object', function(){ const action = fetchLatestVersion(); - expect(action[CALL_API]).to.be.an('object'); - expect(action[CALL_API].endpoint).to.eql('http://localhost:8448/api/latestversion'); - expect(action[CALL_API].method).to.eql('GET'); - expect(action[CALL_API].types).to.be.an('array'); - expect(action[CALL_API].types[0]).to.eql(types.FETCH_LATEST_VERSION_REQUEST); - expect(action[CALL_API].types[1]).to.eql(types.FETCH_LATEST_VERSION_SUCCESS); - expect(action[CALL_API].types[2]).to.eql(types.FETCH_LATEST_VERSION_FAILURE); + expect(action[RSAA]).to.be.an('object'); + expect(action[RSAA].endpoint).to.eql('http://localhost:8448/api/latestversion'); + expect(action[RSAA].method).to.eql('GET'); + expect(action[RSAA].types).to.be.an('array'); + expect(action[RSAA].types[0]).to.eql(types.FETCH_LATEST_VERSION_REQUEST); + expect(action[RSAA].types[1]).to.eql(types.FETCH_LATEST_VERSION_SUCCESS); + expect(action[RSAA].types[2]).to.eql(types.FETCH_LATEST_VERSION_FAILURE); }); }); describe('fetchGitVersion', () => { - it('returns CALL_API action object', function(){ + it('returns RSAA action object', function(){ const action = fetchGitVersion(); - expect(action[CALL_API]).to.be.an('object'); - expect(action[CALL_API].endpoint).to.eql('http://localhost:8448/api/gitversion'); - expect(action[CALL_API].method).to.eql('GET'); - expect(action[CALL_API].types).to.be.an('array'); - expect(action[CALL_API].types[0]).to.eql(types.FETCH_GIT_VERSION_REQUEST); - expect(action[CALL_API].types[1]).to.eql(types.FETCH_GIT_VERSION_SUCCESS); - expect(action[CALL_API].types[2]).to.eql(types.FETCH_GIT_VERSION_FAILURE); + expect(action[RSAA]).to.be.an('object'); + expect(action[RSAA].endpoint).to.eql('http://localhost:8448/api/gitversion'); + expect(action[RSAA].method).to.eql('GET'); + expect(action[RSAA].types).to.be.an('array'); + expect(action[RSAA].types[0]).to.eql(types.FETCH_GIT_VERSION_REQUEST); + expect(action[RSAA].types[1]).to.eql(types.FETCH_GIT_VERSION_SUCCESS); + expect(action[RSAA].types[2]).to.eql(types.FETCH_GIT_VERSION_FAILURE); }); }); }); \ No newline at end of file diff --git a/src-react/__tests__/middlewares/redux-api/ungit-config.test.js b/src-react/__tests__/middlewares/redux-api/ungit-config.test.js index 50aedbc..238c2b9 100644 --- a/src-react/__tests__/middlewares/redux-api/ungit-config.test.js +++ b/src-react/__tests__/middlewares/redux-api/ungit-config.test.js @@ -3,8 +3,9 @@ import sinon from 'sinon'; import expect from 'expect.js'; import configureStore from 'redux-mock-store'; import { createStore, applyMiddleware } from 'redux'; -import { apiMiddleware, CALL_API } from 'redux-api-middleware'; +import { apiMiddleware } from 'redux-api-middleware'; +import { FETCH_HEADER } from '../../utils/constants'; import * as types from 'constants/action-types'; import { fetchUngitConfig } from 'actions/ungit-config'; @@ -17,11 +18,11 @@ describe('redux-api-middleware::ungit-config', () => { beforeEach(() => { nock('http://localhost:8448') .get('/ungit/config') - .reply(200, mockPayload); + .reply(200, mockPayload, FETCH_HEADER); nock('http://localhost:8448') .get('/api/userconfig') - .reply(200, mockPayload); + .reply(200, mockPayload, FETCH_HEADER); }); it('should dispatch \'FETCH_UNGIT_CONFIG_REQUEST\'', done => { @@ -58,7 +59,7 @@ describe('redux-api-middleware::ungit-config', () => { beforeEach(() => { nock('http://localhost:8448') .get('/ungit/config') - .reply(500, null); + .reply(500, null, FETCH_HEADER); }); it('should dispatch \'FETCH_UNGIT_CONFIG_FAILURE\'', done => { diff --git a/src-react/__tests__/middlewares/redux-api/user-config.test.js b/src-react/__tests__/middlewares/redux-api/user-config.test.js index a284dab..a9667fb 100644 --- a/src-react/__tests__/middlewares/redux-api/user-config.test.js +++ b/src-react/__tests__/middlewares/redux-api/user-config.test.js @@ -3,8 +3,9 @@ import sinon from 'sinon'; import expect from 'expect.js'; import configureStore from 'redux-mock-store'; import { createStore, applyMiddleware } from 'redux'; -import { apiMiddleware, CALL_API } from 'redux-api-middleware'; +import { apiMiddleware } from 'redux-api-middleware'; +import { FETCH_HEADER } from '../../utils/constants'; import * as types from 'constants/action-types'; import { fetchUserConfig } from 'actions/user-config'; @@ -17,7 +18,7 @@ describe('redux-api-middleware::user-config', () => { beforeEach(() => { nock('http://localhost:8448') .get('/api/userconfig') - .reply(200, mockPayload); + .reply(200, mockPayload, FETCH_HEADER); }); it('should dispatch \'FETCH_USER_CONFIG_REQUEST\'', done => { @@ -54,7 +55,7 @@ describe('redux-api-middleware::user-config', () => { beforeEach(() => { nock('http://localhost:8448') .get('/api/userconfig') - .reply(500, null); + .reply(500, null, FETCH_HEADER); }); it('should dispatch \'FETCH_USER_CONFIG_FAILURE\'', done => { diff --git a/src-react/__tests__/middlewares/redux-api/version.test.js b/src-react/__tests__/middlewares/redux-api/version.test.js index fa795b2..9916c3d 100644 --- a/src-react/__tests__/middlewares/redux-api/version.test.js +++ b/src-react/__tests__/middlewares/redux-api/version.test.js @@ -3,8 +3,9 @@ import sinon from 'sinon'; import expect from 'expect.js'; import configureStore from 'redux-mock-store'; import { createStore, applyMiddleware } from 'redux'; -import { apiMiddleware, CALL_API } from 'redux-api-middleware'; +import { apiMiddleware } from 'redux-api-middleware'; +import { FETCH_HEADER } from '../../utils/constants'; import * as types from 'constants/action-types'; import { fetchLatestVersion, fetchGitVersion } from 'actions/version'; @@ -17,7 +18,7 @@ describe('redux-api-middleware::version', () => { beforeEach(() => { nock('http://localhost:8448') .get('/api/latestversion') - .reply(200, mockPayload); + .reply(200, mockPayload, FETCH_HEADER); }); it('should dispatch \'FETCH_LATEST_VERSION_REQUEST\'', done => { @@ -54,7 +55,7 @@ describe('redux-api-middleware::version', () => { beforeEach(() => { nock('http://localhost:8448') .get('/api/latestversion') - .reply(500, null); + .reply(500, null, FETCH_HEADER); }); it('should dispatch \'FETCH_LATEST_VERSION_FAILURE\'', done => { @@ -79,7 +80,7 @@ describe('redux-api-middleware::version', () => { beforeEach(() => { nock('http://localhost:8448') .get('/api/gitversion') - .reply(200, mockPayload); + .reply(200, mockPayload, FETCH_HEADER); }); it('should dispatch \'FETCH_GIT_VERSION_REQUEST\'', done => { @@ -116,7 +117,7 @@ describe('redux-api-middleware::version', () => { beforeEach(() => { nock('http://localhost:8448') .get('/api/gitversion') - .reply(500, null); + .reply(500, null, FETCH_HEADER); }); it('should dispatch \'FETCH_GIT_VERSION_FAILURE\'', done => { diff --git a/src-react/__tests__/utils/constants.js b/src-react/__tests__/utils/constants.js new file mode 100644 index 0000000..cfc587d --- /dev/null +++ b/src-react/__tests__/utils/constants.js @@ -0,0 +1,4 @@ +export const FETCH_HEADER = { + 'Access-Control-Allow-Origin': '*', + 'Content-type': 'application/json' +}; \ No newline at end of file diff --git a/src-react/actions/ungit-config.js b/src-react/actions/ungit-config.js index ce346fa..e2cd171 100644 --- a/src-react/actions/ungit-config.js +++ b/src-react/actions/ungit-config.js @@ -1,11 +1,11 @@ import * as types from 'constants/action-types'; -import { CALL_API } from 'redux-api-middleware'; +import { RSAA } from 'redux-api-middleware'; import { fetchUserConfig } from './user-config'; import store from 'store'; export function fetchUngitConfig() { return { - [CALL_API]: { + [RSAA]: { endpoint: 'http://localhost:8448/ungit/config', method: 'GET', types: [ diff --git a/src-react/actions/user-config.js b/src-react/actions/user-config.js index 62d0772..ff46fa0 100644 --- a/src-react/actions/user-config.js +++ b/src-react/actions/user-config.js @@ -1,9 +1,9 @@ import * as types from 'constants/action-types'; -import { CALL_API } from 'redux-api-middleware'; +import { RSAA } from 'redux-api-middleware'; export function fetchUserConfig() { return { - [CALL_API]: { + [RSAA]: { endpoint: 'http://localhost:8448/api/userconfig', method: 'GET', types: [