step 6 exercise

This commit is contained in:
Ken
2019-02-19 22:20:09 -08:00
parent 2b41788cc2
commit 72ace4f43c
12 changed files with 39 additions and 159 deletions
+1 -1
View File
@@ -16,6 +16,6 @@ From the official documentation site:
2. Open `exercise/src/reducers/pureFunctions.ts` and fill in the missing body of the pure functions.
3. Open `exercise/src/reducers/index.ts` and observe how those pureFunctions are called.
3. Open `exercise/src/reducers/index.ts` and fill in the missing case statements for the switch of `action.type`.
4. Open `exercise/src/reducers/pureFunctions.spec.ts` and implement tests for the functions you wrote for `remove`, `complete`, and `clear`.
+5 -9
View File
@@ -1,19 +1,15 @@
import { Store } from '../store';
import { addTodo, remove, complete, clear } from './pureFunctions';
import { addTodo, remove, complete } from './pureFunctions';
export function reducer(state: Store['todos'], payload: any): Store['todos'] {
switch (payload.type) {
case 'addTodo':
return addTodo(state, payload.id, payload.label);
case 'remove':
return remove(state, payload.id);
case 'complete':
return complete(state, payload.id);
case 'clear':
return clear(state);
// Fill in the blanks here for:
// - remove
// - complete
// - clear
}
return state;