Skip to content
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

incorporate more agency info to explorer page #745

Merged
merged 2 commits into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Rename agency reducer to agencies
  • Loading branch information
Jeremia Kimelman committed May 10, 2017
commit b346fc5e25ba9de8698e8b17ee02681f0445a8f0
4 changes: 2 additions & 2 deletions src/components/Explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Explorer extends React.Component {
return <NotFound />
}

const { agency, filters, nibrs, sidebar, summaries, ucr } = appState
const { agencies, filters, nibrs, sidebar, summaries, ucr } = appState
const { since, until } = filters
const noNibrs = ['violent-crime', 'property-crime']
const participation = ucrParticipation(place)
Expand Down Expand Up @@ -109,7 +109,7 @@ class Explorer extends React.Component {
<div className="site-content">
<div className="container-main mx-auto px2 md-py3 lg-px8">
<ExplorerHeader
agency={agency}
agency={agencies}
crime={crime}
place={place}
placeType={placeType}
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/no-unresolved */
import { combineReducers } from 'redux'

import agency from './agency'
import agencies from './agencies'
import feedback from './feedback'
import filters from './filters'
import glossary from './glossary'
Expand All @@ -12,7 +12,7 @@ import summaries from './summary'
import ucr from './ucr'

export default combineReducers({
agency,
agencies,
feedback,
filters,
glossary,
Expand Down
38 changes: 38 additions & 0 deletions test/reducers/agencies.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint no-undef: 0 */

import { AGENCY_FETCHING, AGENCY_RECEIVED } from '../../src/actions/constants'
import reducer from '../../src/reducers/agencies'

describe('agencies reducer', () => {
describe('initial state', () => {
it('should have loading set to false', () => {
const initialState = reducer(undefined, { type: 'fake' })
expect(initialState.loading).toEqual(false)
})
})

describe('AGENCY_FETCHING action type', () => {
it('should set loading to true', () => {
const initialState = reducer(undefined, { type: AGENCY_FETCHING })
expect(initialState.loading).toEqual(true)
})
})

describe('AGENCY_RECEIVED action type', () => {
it('should set loading to false', () => {
const initialState = reducer(undefined, { type: AGENCY_RECEIVED })
expect(initialState.loading).toEqual(false)
})

it('should add any agencies to state', () => {
const action = {
type: AGENCY_RECEIVED,
agency: {
FAKEORI: ['testing', 'data'],
},
}
const s = reducer(undefined, action)
expect(s.FAKEORI).toEqual(action.agency.FAKEORI)
})
})
})