Skip to content

Fix type error cannot read property async #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ install:
- npm install

script:
- node -v
- npm run test-react
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -152,7 +152,7 @@
"<rootDir>/config/localStorageMock.js"
],
"testPathIgnorePatterns": [
"<rootDir>[/\\\\](build|docs|node_modules|scripts|clicktests)[/\\\\]"
"<rootDir>[/\\\\](build|docs|node_modules|scripts|clicktests|src-react/__tests__/utils)[/\\\\]"
],
"testEnvironment": "node",
"testURL": "http://localhost",
Expand Down
20 changes: 10 additions & 10 deletions src-react/__tests__/actions/ungit-config.test.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
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';
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);
});
});
});
18 changes: 9 additions & 9 deletions src-react/__tests__/actions/user-config.test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
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';
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);
});
});
});
34 changes: 17 additions & 17 deletions src-react/__tests__/actions/version.test.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
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';
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);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we require util without dots?
ex. import { FETCH_HEADER } from 'utils/constants'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import * as types from 'constants/action-types';
import { fetchUngitConfig } from 'actions/ungit-config';

Expand All @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand Down
7 changes: 4 additions & 3 deletions src-react/__tests__/middlewares/redux-api/user-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand Down
11 changes: 6 additions & 5 deletions src-react/__tests__/middlewares/redux-api/version.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand All @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand Down
4 changes: 4 additions & 0 deletions src-react/__tests__/utils/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const FETCH_HEADER = {
'Access-Control-Allow-Origin': '*',
'Content-type': 'application/json'
};
4 changes: 2 additions & 2 deletions src-react/actions/ungit-config.js
Original file line number Diff line number Diff line change
@@ -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: [
Expand Down
4 changes: 2 additions & 2 deletions src-react/actions/user-config.js
Original file line number Diff line number Diff line change
@@ -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: [
Expand Down