Skip to content

Commit 4eb9a37

Browse files
author
ogaoga
committed
Added test cases for Redux.
1 parent 5988ae7 commit 4eb9a37

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

src/reducers/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11

2-
/*
3-
*/
4-
52
const initialState = {
63
data: null,
74
text: '',

test/test-actions.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import expect from 'expect';
2+
3+
import {updateText} from '../src/actions/index'
4+
5+
let params = [
6+
{
7+
title: 'updateText',
8+
actual: updateText('abc').type,
9+
expected: 'UPDATE_TEXT'
10+
}
11+
];
12+
13+
describe('actions', () => {
14+
params.forEach((param) => {
15+
it(param.title, () => {
16+
expect(param.actual).toEqual(param.expected);
17+
});
18+
});
19+
});

test/test-reducer.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import expect from 'expect';
2+
3+
import {updateText, clearText} from '../src/actions'
4+
import reducer from '../src/reducers'
5+
6+
const params = [
7+
{
8+
title: 'updateText',
9+
action: updateText('abc'),
10+
expected: {
11+
data: null,
12+
text: 'abc',
13+
autoFormat: false
14+
}
15+
},
16+
{
17+
title: 'clearText',
18+
action: clearText(),
19+
expected: {
20+
data: null,
21+
text: '',
22+
autoFormat: false
23+
}
24+
}
25+
]
26+
27+
28+
describe('reducer', () => {
29+
30+
let state = undefined
31+
32+
params.forEach((param) => {
33+
it(param.title, () => {
34+
expect(reducer(state, param.action)).toEqual(param.expected);
35+
});
36+
});
37+
});

0 commit comments

Comments
 (0)