From 1f51f3260d90914fba89720f63813a3f41f5e5f1 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 6 May 2018 21:11:26 +0900 Subject: add tests --- test/background/reducers/tab.test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/background/reducers/tab.test.js (limited to 'test/background/reducers') diff --git a/test/background/reducers/tab.test.js b/test/background/reducers/tab.test.js new file mode 100644 index 0000000..09fa8a7 --- /dev/null +++ b/test/background/reducers/tab.test.js @@ -0,0 +1,22 @@ +import actions from 'background/actions'; +import tabReducer from 'background/reducers/tab'; + +describe("tab reducer", () => { + it('return the initial state', () => { + let state = tabReducer(undefined, {}); + expect(state.previousSelected).to.equal(-1); + expect(state.currentSelected).to.equal(-1); + }); + + it('return next state for TAB_SELECTED', () => { + let state = undefined; + + state = tabReducer(state, { type: actions.TAB_SELECTED, tabId: 123 }); + expect(state.previousSelected).to.equal(-1); + expect(state.currentSelected).to.equal(123); + + state = tabReducer(state, { type: actions.TAB_SELECTED, tabId: 456 }); + expect(state.previousSelected).to.equal(123); + expect(state.currentSelected).to.equal(456); + }); +}); -- cgit v1.2.3