Skip to content

Commit d80ccc2

Browse files
committed
write tests and docs for window module
1 parent a4fd5de commit d80ccc2

File tree

4 files changed

+35
-29
lines changed

4 files changed

+35
-29
lines changed

src/modules/window/Quit/index.tsx

-29
This file was deleted.

src/modules/window/actions.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import {QUIT, WINDOW_TOGGLE} from './types';
22

3+
/**
4+
* Toggle window open action
5+
* @returns Action
6+
*/
37
export function windowToggle(): Action {
48
return { type: WINDOW_TOGGLE };
59
}
610

11+
/**
12+
* Toggle window closed action
13+
* @returns Action
14+
*/
715
export function quit(): Action {
816
return { type: QUIT };
917
}

src/modules/window/reducer.test.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import reducer from './reducer';
2+
3+
describe('window reducer', () => {
4+
5+
it('should initialize false', () => {
6+
const action = { type: 'null' };
7+
expect(reducer(undefined, action)).toBe(false);
8+
});
9+
10+
it('should set to false on QUIT', () => {
11+
const action = { type: 'QUIT' };
12+
expect(reducer(true, action)).toBe(false);
13+
});
14+
15+
it('should toggle the WINDOW_TOGGLE', () => {
16+
const action = { type: 'WINDOW_TOGGLE' };
17+
expect(reducer(false, action)).toBe(true);
18+
expect(reducer(true, action)).toBe(false);
19+
});
20+
21+
});

src/modules/window/reducer.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import {QUIT, WINDOW_TOGGLE} from './types';
22

3+
/**
4+
* Window open status reducer
5+
* @param {} open=false
6+
* @param {Action} action
7+
* @returns boolean window open status
8+
*/
39
export default function windowReducer(
410
open = false, action: Action
511
): boolean {

0 commit comments

Comments
 (0)