Skip to content

Commit ea5941b

Browse files
committed
add hint tests
1 parent d8192a1 commit ea5941b

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

src/modules/editor/reducer.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// <reference path="../../typings/globals/jest/index.d.ts" />
2+
23
import reducer from './reducer';
34
import * as types from './types';
45

src/modules/hints/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import {HINT_POSITION_SET} from './types';
2-
2+
/**
3+
* sets hint index
4+
* @param {} hintPosition=0
5+
* @param {Action} action
6+
* @returns number
7+
*/
38
export default function hintPositionReducer(
49
hintPosition = 0, action: Action
510
): number {

src/modules/hints/reducer.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// <reference path="../../typings/globals/jest/index.d.ts" />
2+
3+
import reducer from './index';
4+
import { HINT_POSITION_SET } from './types';
5+
6+
describe('hint reducer', () => {
7+
8+
it('should do nothing if no triggered action type', () => {
9+
const action = { type: 'unknown' };
10+
expect(reducer(undefined, action)).toBe(0);
11+
});
12+
13+
it('should handle HINT_POSITION_SET', () => {
14+
const hintPosition = 2;
15+
const action = { type: HINT_POSITION_SET, payload: { hintPosition } };
16+
expect(reducer(0, action)).toBe(hintPosition);
17+
});
18+
19+
});

0 commit comments

Comments
 (0)