mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
adding some redux steps
This commit is contained in:
20
step2-06/src/reducers/pureFunctions.spec.ts
Normal file
20
step2-06/src/reducers/pureFunctions.spec.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { addTodo } from './pureFunctions';
|
||||
import { Store } from '../store';
|
||||
|
||||
describe('TodoApp reducers', () => {
|
||||
it('can add an item', () => {
|
||||
const state = <Store>{
|
||||
todos: {},
|
||||
filter: 'all'
|
||||
};
|
||||
|
||||
const newState = addTodo(state, 'item1');
|
||||
|
||||
const keys = Object.keys(newState.todos);
|
||||
|
||||
expect(newState).not.toBe(state);
|
||||
expect(keys.length).toBe(1);
|
||||
expect(newState.todos[keys[0]].label).toBe('item1');
|
||||
expect(newState.todos[keys[0]].completed).toBeFalsy();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user