Skip to content

Commit

Permalink
yarn run lint --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
christinach committed Feb 21, 2020
1 parent 49926b1 commit 3b27812
Show file tree
Hide file tree
Showing 17 changed files with 343 additions and 317 deletions.
29 changes: 12 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,29 @@ jobs:
- checkout
# Restore the dependency cache
- restore_cache:
key: be-redux-react-{{ checksum "package-lock.json" }}

keys:
- v1-dependencies-{{ checksum "package-lock.json" }}
- v1-dependencies-
- run:
name: Install dependencies with NPM
command: npm install

# Save the dependency cache
- save_cache:
key: be-redux-react-{{ checksum "package-lock.json" }}
key: v1-dependencies-{{ checksum "package-lock.json" }}
paths:
- "node_modules"
- node_modules

# I kept this commented because it fails
# - run:
# name: Validate the style of the code
# command: yarn lint

- run:
name: Run tests
command: |
mkdir /tmp/test-results
npm test
# Collect reports
- store_artifacts:
path: /tmp/test-results

- store_test_results:
path: /tmp/test-results
destination: test-results
name: "Run Jest and Collect Coverage Reports"
command: yarn test --collectCoverage=true
- store_artifacts:
path: coverage

workflows:
version: 2
Expand Down
21 changes: 9 additions & 12 deletions src/__tests__/actions.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'
import * as types from '../types'
Expand Down Expand Up @@ -32,28 +31,26 @@ describe('actions', () => {

it('dispatches REQUEST_PROVIDERS and RECEIVE_PROVIDERS when providers have been requested and received from the API', () => {
// These should be loaded from fixture files
const provider1 = {

}
const provider1 = {}

const provider2 = {

}
const provider2 = {}

fetchMock.getOnce('http://localhost:3000/browse/providers', {
status: 200,
headers: { 'Content-Type': 'application/json' },
body: {
data: [
provider1,
provider2
]
data: [provider1, provider2]
}
})

const expectedActions = [
{ type: types.REQUEST_PROVIDERS, isRequesting: true, providers: [] },
{ type: types.RECEIVE_PROVIDERS, isRequesting: false, providers: [provider1, provider2], receivedAt: currentTime }
{
type: types.RECEIVE_PROVIDERS,
isRequesting: false,
providers: [provider1, provider2],
receivedAt: currentTime
}
]
const store = mockStore({ providers: [] })

Expand Down
16 changes: 10 additions & 6 deletions src/actions.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { selectProvider, updateProviders, clearProvider } from './actions/providers';
import { createSession, clearSession } from './actions/sessions';
import { authorize, createAuthorization } from './actions/authorizations';
import { getRootContainer, getContainer } from './actions/containers';
import {
selectProvider,
updateProviders,
clearProvider
} from './actions/providers'
import { createSession, clearSession } from './actions/sessions'
import { authorize, createAuthorization } from './actions/authorizations'
import { getRootContainer, getContainer } from './actions/containers'
import {
createUpload,
selectContainerForUpload,
deselectContainerForUpload,
selectBytestreamForUpload,
deselectBytestreamForUpload,
clearUpload
} from './actions/uploads';
} from './actions/uploads'

export {
selectProvider,
Expand All @@ -27,4 +31,4 @@ export {
selectBytestreamForUpload,
deselectBytestreamForUpload,
clearUpload
};
}
56 changes: 29 additions & 27 deletions src/actions/authorizations.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as types from '../types';
import { config } from '../bees';
import * as types from '../types'
import { config } from '../bees'

/**
* Authorizations
Expand All @@ -10,52 +10,54 @@ function receiveWebToken(authToken) {
type: types.RECEIVE_WEB_TOKEN,
isRequesting: false,
authToken
};
}
}

function requestAuthorization() {
return {
type: types.REQUEST_AUTHORIZATION,
authToken: null,
isRequesting: true
};
}
}

function receiveAuthorization(response) {
const authToken = response.authToken;
const authToken = response.authToken
return {
type: types.RECEIVE_AUTHORIZATION,
isRequesting: false,
receivedAt: Date.now(),
authToken
};
}
}

export function createAuthorization() {
return (dispatch, getState) => {
dispatch(requestAuthorization());

const state = getState();
const provider = state.selectedProvider;

const endpoint = config.baseUrl;
const requestUrl = `${endpoint}/providers/${provider.id}/authorize`;
const request = fetch(requestUrl);

return request.then(response => {
const jsonResponse = response.json();
return jsonResponse.then(json => {
return dispatch(receiveAuthorization(json));
});
},
error => {
console.error(error);
});
};
dispatch(requestAuthorization())

const state = getState()
const provider = state.selectedProvider

const endpoint = config.baseUrl
const requestUrl = `${endpoint}/providers/${provider.id}/authorize`
const request = fetch(requestUrl)

return request.then(
response => {
const jsonResponse = response.json()
return jsonResponse.then(json => {
return dispatch(receiveAuthorization(json))
})
},
error => {
console.error(error)
}
)
}
}

export function authorize(authToken) {
return (dispatch, getState) => {
return dispatch(receiveWebToken(authToken));
};
return dispatch(receiveWebToken(authToken))
}
}
Loading

0 comments on commit 3b27812

Please sign in to comment.