-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
resolved #81
- Loading branch information
Mirosław Bogacz
authored
Nov 27, 2017
1 parent
b4b5187
commit 2ed6b12
Showing
1 changed file
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import * as filtersActions from '../actions/filters.actions'; | ||
import { filtersReducer } from './filters.reducer'; | ||
|
||
describe('filtersReducer', () => { | ||
|
||
describe('when reducer doesnt get any params', () => { | ||
|
||
it('shoud return default state', () => { | ||
|
||
const emptyAction = { type: '' } as any; | ||
expect(filtersReducer(undefined, emptyAction)).toEqual({ model: {} }) | ||
|
||
}); | ||
|
||
}); | ||
|
||
describe('when reducer get UPDATE action with out state', () => { | ||
|
||
it('should return value with new element from payload', () => { | ||
|
||
const state = { model: {} }; | ||
const actionPayload = { keywords: 'test keywords' }; | ||
const action = new filtersActions.Update(actionPayload); | ||
const result = filtersReducer(state, action); | ||
const expected = { model: actionPayload }; | ||
|
||
expect(result).toEqual(expected); | ||
|
||
}); | ||
|
||
}); | ||
|
||
describe('when reducer get UPDATE action', () => { | ||
|
||
it('should return value with new element from payload', () => { | ||
|
||
const state = { model: {} }; | ||
const actionPayload = { keywords: 'test keywords' }; | ||
const action = new filtersActions.Update(actionPayload); | ||
const result = filtersReducer(state, action); | ||
const expected = { model: actionPayload }; | ||
|
||
expect(result).toEqual(expected); | ||
|
||
}); | ||
|
||
}); | ||
|
||
describe('when reducer get UPDATE action', () => { | ||
|
||
it('should return value with updated element from payload', () => { | ||
|
||
const state = { model: { keywords: 'old value' } }; | ||
const actionPayload = { keywords: 'new value' }; | ||
const action = new filtersActions.Update(actionPayload); | ||
const result = filtersReducer(state, action); | ||
const expected = { model: actionPayload }; | ||
|
||
expect(result).toEqual(expected); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
|