mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-07-12 15:18:34 +08:00
step 6 exercise
This commit is contained in:
+1
-1
@@ -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`.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user