Skip to content

Commit 1e12723

Browse files
committed
add action creator unit test
1 parent 8d82c4a commit 1e12723

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as actions from '../../src/todos/actions.js';
2+
import * as actionTypes from '../../src/todos/actionTypes.js';
3+
4+
describe('todos/actions', () => {
5+
describe('addTodo', () => {
6+
const addTodo = actions.addTodo
7+
8+
it('should create an action to add todo', () => {
9+
const text = 'first todo';
10+
const action = addTodo(text);
11+
12+
expect(action.text).toBe(text);
13+
expect(action.completed).toBe(false);
14+
expect(action.type).toBe(actionTypes.ADD_TODO);
15+
});
16+
17+
it('should have different id for different actions', () => {
18+
const text = 'first todo';
19+
const action1 = addTodo(text);
20+
const action2 = addTodo(text);
21+
22+
expect(action1.id !== action2.id).toBe(true);
23+
});
24+
});
25+
});

0 commit comments

Comments
 (0)