aboutsummaryrefslogtreecommitdiff
path: root/test/background/reducers/setting.test.js
blob: 24d02eae931031f6c342987dbe60efe5007192e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import actions from 'background/actions';
import settingReducer from 'background/reducers/setting';

describe("setting reducer", () => {
  it('return the initial state', () => {
    let state = settingReducer(undefined, {});
    expect(state).to.have.deep.property('value', {});
  });

  it('return next state for SETTING_SET_SETTINGS', () => {
    let action = {
      type: actions.SETTING_SET_SETTINGS,
      value: { key: 123 },
    };
    let state = settingReducer(undefined, action);
    expect(state).to.have.deep.property('value', { key: 123 });
  });

  it('return next state for SETTING_SET_PROPERTY', () => {
    let state = {
      value: {
        properties: { smoothscroll: true }
      }
    }
    let action = {
      type: actions.SETTING_SET_PROPERTY,
      name: 'encoding',
      value: 'utf-8',
    };
    state = settingReducer(state, action);

    expect(state.value.properties).to.have.property('smoothscroll', true);
    expect(state.value.properties).to.have.property('encoding', 'utf-8');
  });
});