diff options
| author | Thomas Haddad | 2017-01-09 11:39:36 +0100 |
|---|---|---|
| committer | Thomas Haddad | 2017-01-09 11:40:43 +0100 |
| commit | 7b57387a03a5f100320f91d7c8cb25e29d126815 (patch) | |
| tree | 9395ce22242e561052896995df5273c876c787da /spec/javascripts | |
| parent | b6c227a9347d21dfc7226b734ac608346d973c4f (diff) | |
| download | chouette-core-7b57387a03a5f100320f91d7c8cb25e29d126815.tar.bz2 | |
Add pagination spec and move totalCount into pagination for further and easier updates
Signed-off-by: Thomas Shawarma Haddad <thomas.haddad@af83.com>
Diffstat (limited to 'spec/javascripts')
| -rw-r--r-- | spec/javascripts/journey_patterns/reducers/journey_patterns_spec.js (renamed from spec/javascripts/journey_patterns/reducers_spec.js) | 0 | ||||
| -rw-r--r-- | spec/javascripts/journey_patterns/reducers/pagination_spec.js | 77 |
2 files changed, 77 insertions, 0 deletions
diff --git a/spec/javascripts/journey_patterns/reducers_spec.js b/spec/javascripts/journey_patterns/reducers/journey_patterns_spec.js index 422c97fee..422c97fee 100644 --- a/spec/javascripts/journey_patterns/reducers_spec.js +++ b/spec/javascripts/journey_patterns/reducers/journey_patterns_spec.js diff --git a/spec/javascripts/journey_patterns/reducers/pagination_spec.js b/spec/javascripts/journey_patterns/reducers/pagination_spec.js new file mode 100644 index 000000000..a99e8ff85 --- /dev/null +++ b/spec/javascripts/journey_patterns/reducers/pagination_spec.js @@ -0,0 +1,77 @@ +var reducer = require('es6_browserified/journey_patterns/reducers/pagination') +let state = { + page : 2, + totalCount : 25 +} +let currentPage = 2 +const dispatch = function(){} + +describe('pagination reducer, given parameters allowing page change', () => { + + it('should return the initial state', () => { + expect( + reducer(undefined, {}) + ).toEqual({}) + }) + + it('should handle GO_TO_NEXT_PAGE and change state', () => { + expect( + reducer(state, { + type: 'GO_TO_NEXT_PAGE', + dispatch, + currentPage, + nextPage : true + }) + ).toEqual(Object.assign({}, state, {page : state.page + 1})) + }) + + it('should return GO_TO_PREVIOUS_PAGE and change state', () => { + expect( + reducer(state, { + type: 'GO_TO_PREVIOUS_PAGE', + dispatch, + currentPage, + nextPage : false + }) + ).toEqual(Object.assign({}, state, {page : state.page - 1})) + }) +}) + + +describe('pagination reducer, given parameters not allowing to go to previous page', () => { + + beforeEach(()=>{ + state.page = 1 + currentPage = 1 + }) + + it('should return GO_TO_PREVIOUS_PAGE and not change state', () => { + expect( + reducer(state, { + type: 'GO_TO_PREVIOUS_PAGE', + dispatch, + currentPage, + nextPage : false + }) + ).toEqual(state) + }) +}) + +describe('pagination reducer, given parameters not allowing to go to next page', () => { + + beforeEach(()=>{ + state.page = 3 + currentPage = 3 + }) + + it('should return GO_TO_NEXT_PAGE and not change state', () => { + expect( + reducer(state, { + type: 'GO_TO_NEXT_PAGE', + dispatch, + currentPage, + nextPage : false + }) + ).toEqual(state) + }) +}) |
