aboutsummaryrefslogtreecommitdiff
path: root/test/background/reducers/tab.test.js
blob: 09fa8a74e3c7c30a388979e8e3af2071e6c72404 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);
  });
});