forked from bcgov/range-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kyubinhan
committed
Jun 23, 2018
1 parent
e0d352f
commit d82bbf4
Showing
7 changed files
with
99 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/api/fakeAgreements.js → src/tests/intergration/fakeAgreements.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable quotes, comma-dangle */ | ||
const paginatedFakeAgreements = { | ||
"perPage": 10, | ||
"currentPage": 1, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as fakeAgreements } from './fakeAgreements'; | ||
export { default as fakePlan } from './fakePlan'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { normalize } from 'normalizr'; | ||
import planReducer from '../../reducers/planReducer'; | ||
import { storePlan } from '../../actions/storeActions'; | ||
import * as schema from '../../actionCreators/schema'; | ||
|
||
const initialState = { | ||
plans: {}, | ||
planIds: [], | ||
pastures: {}, | ||
grazingSchedules: {}, | ||
ministerIssues: {}, | ||
}; | ||
|
||
const mockPlanData = { | ||
id: 'plan_id', | ||
rangeName: 'hello', | ||
pastures: [ | ||
{ | ||
id: 'pasture_id', | ||
name: 'Pasture 1', | ||
}, | ||
], | ||
grazingSchedules: [ | ||
{ | ||
id: 'grazing_schedule_id', | ||
year: 2018, | ||
}, | ||
], | ||
ministerIssues: [ | ||
{ | ||
id: 'minister_issue_id', | ||
detail: 'detail', | ||
}, | ||
], | ||
}; | ||
|
||
const mockState = { | ||
plans: { | ||
plan_id: { | ||
id: 'plan_id', | ||
rangeName: 'hello', | ||
pastures: ['pasture_id'], | ||
grazingSchedules: ['grazing_schedule_id'], | ||
ministerIssues: ['minister_issue_id'], | ||
}, | ||
}, | ||
planIds: ['plan_id'], | ||
pastures: { | ||
pasture_id: { | ||
id: 'pasture_id', | ||
name: 'Pasture 1', | ||
}, | ||
}, | ||
grazingSchedules: { | ||
grazing_schedule_id: { | ||
id: 'grazing_schedule_id', | ||
year: 2018, | ||
}, | ||
}, | ||
ministerIssues: { | ||
minister_issue_id: { | ||
id: 'minister_issue_id', | ||
detail: 'detail', | ||
}, | ||
}, | ||
}; | ||
|
||
describe('Plan reducer', () => { | ||
it('Initialized with the initial state', () => { | ||
expect(planReducer(undefined, {})).toEqual(initialState); | ||
}); | ||
|
||
describe('Handles \'STORE_PLAN\'', () => { | ||
it('Correctly stores the plans and related fields with initial state', () => { | ||
const normalized = normalize(mockPlanData, schema.plan); | ||
expect(planReducer(initialState, storePlan(normalized))).toEqual(mockState); | ||
}); | ||
|
||
it('Correctly stores the plans and related fields with pre-existing state', () => { | ||
const normalized = normalize(mockPlanData, schema.plan); | ||
expect(planReducer(mockState, storePlan(normalized))).toEqual(mockState); | ||
}); | ||
}); | ||
}); |