From 03b6982405993a9a3ffb4b5fbe78ed683ab47057 Mon Sep 17 00:00:00 2001 From: Jack Reed <phillipjreed@gmail.com> Date: Mon, 5 Mar 2018 15:17:06 -0700 Subject: [PATCH] add tests for reducers --- tests/reducers/windows.test.js | 54 ++++++++++++++++++++++++++++++++ tests/reducers/workspace.test.js | 13 ++++++++ 2 files changed, 67 insertions(+) create mode 100644 tests/reducers/windows.test.js create mode 100644 tests/reducers/workspace.test.js diff --git a/tests/reducers/windows.test.js b/tests/reducers/windows.test.js new file mode 100644 index 000000000..6dc83f303 --- /dev/null +++ b/tests/reducers/windows.test.js @@ -0,0 +1,54 @@ +import reducer from '../../reducers/windows'; +import ActionTypes from '../../action-types'; + +describe('windows reducer', () => { + it('should handle ADD_WINDOW', () => { + expect(reducer([], { + type: ActionTypes.ADD_WINDOW, + })).toEqual([ + {}, + ]); + }); + it('should handle REMOVE_WINDOW', () => { + expect(reducer([ + { + id: 'abc123', + }, + ], { + type: ActionTypes.REMOVE_WINDOW, + windowId: 'abc123', + })).toEqual([]); + }); + it('should handle NEXT_CANVAS', () => { + expect(reducer([ + { + id: 'abc123', + canvasIndex: 1, + }, + ], { + type: ActionTypes.NEXT_CANVAS, + windowId: 'abc123', + })).toEqual([ + { + id: 'abc123', + canvasIndex: 2, + }, + ]); + }); + it('should handle PREVIOUS_CANVAS', () => { + expect(reducer([ + { + id: 'abc123', + canvasIndex: 4, + }, + ], { + type: ActionTypes.PREVIOUS_CANVAS, + windowId: 'abc123', + })).toEqual([ + { + id: 'abc123', + canvasIndex: 3, + }, + ]); + }); +}); diff --git a/tests/reducers/workspace.test.js b/tests/reducers/workspace.test.js new file mode 100644 index 000000000..7205d075c --- /dev/null +++ b/tests/reducers/workspace.test.js @@ -0,0 +1,13 @@ +import reducer from '../../reducers/workspace'; +import ActionTypes from '../../action-types'; + +describe('workspace reducer', () => { + it('should handle FOCUS_WINDOW', () => { + expect(reducer([], { + type: ActionTypes.FOCUS_WINDOW, + windowId: 'abc123', + })).toEqual({ + focusedWindowId: 'abc123', + }); + }); +}); -- GitLab