You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

55 lines
1.7 KiB

import * as actions from 'settings/actions';
7 years ago
import settingReducer from 'settings/reducers/setting';
6 years ago
describe("settings setting reducer", () => {
7 years ago
it('return the initial state', () => {
let state = settingReducer(undefined, {});
expect(state).to.have.deep.property('source', 'json');
6 years ago
expect(state).to.have.deep.property('error', '');
7 years ago
});
it('return next state for SETTING_SET_SETTINGS', () => {
let action = {
type: actions.SETTING_SET_SETTINGS,
6 years ago
source: 'json',
json: '{ "key": "value" }',
6 years ago
form: {},
7 years ago
};
let state = settingReducer(undefined, action);
6 years ago
expect(state).to.have.deep.property('source', 'json');
expect(state).to.have.deep.property('json', '{ "key": "value" }');
6 years ago
expect(state).to.have.deep.property('form', {});
});
it('return next state for SETTING_SHOW_ERROR', () => {
let action = {
type: actions.SETTING_SHOW_ERROR,
error: 'bad value',
6 years ago
json: '{}',
};
let state = settingReducer(undefined, action);
expect(state).to.have.deep.property('error', 'bad value');
expect(state).to.have.deep.property('json', '{}');
});
it('return next state for SETTING_SWITCH_TO_FORM', () => {
let action = {
type: actions.SETTING_SWITCH_TO_FORM,
form: {},
};
let state = settingReducer(undefined, action);
expect(state).to.have.deep.property('form', {});
expect(state).to.have.deep.property('source', 'form');
});
it('return next state for SETTING_SWITCH_TO_JSON', () => {
let action = {
type: actions.SETTING_SWITCH_TO_JSON,
json: '{}',
};
let state = settingReducer(undefined, action);
expect(state).to.have.deep.property('json', '{}');
expect(state).to.have.deep.property('source', 'json');
7 years ago
});
});