A fork of https://github.com/ueokande/vim-vixen
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.
132 lines
3.9 KiB
132 lines
3.9 KiB
7 years ago
|
import actions from 'console/actions';
|
||
|
import reducer from 'console/reducers';
|
||
7 years ago
|
|
||
|
describe("console reducer", () => {
|
||
|
it('return the initial state', () => {
|
||
7 years ago
|
let state = reducer(undefined, {});
|
||
7 years ago
|
expect(state).to.have.property('mode', '');
|
||
|
expect(state).to.have.property('messageText', '');
|
||
7 years ago
|
expect(state).to.have.property('consoleText', '');
|
||
7 years ago
|
expect(state).to.have.deep.property('completions', []);
|
||
6 years ago
|
expect(state).to.have.property('select', -1);
|
||
7 years ago
|
});
|
||
|
|
||
7 years ago
|
it('return next state for CONSOLE_HIDE', () => {
|
||
|
let action = { type: actions.CONSOLE_HIDE };
|
||
|
let state = reducer({ mode: 'error' }, action);
|
||
|
expect(state).to.have.property('mode', '');
|
||
|
})
|
||
|
|
||
7 years ago
|
it('return next state for CONSOLE_SHOW_COMMAND', () => {
|
||
|
let action = { type: actions.CONSOLE_SHOW_COMMAND, text: 'open ' };
|
||
7 years ago
|
let state = reducer({}, action);
|
||
7 years ago
|
expect(state).to.have.property('mode', 'command');
|
||
7 years ago
|
expect(state).to.have.property('consoleText', 'open ');
|
||
7 years ago
|
});
|
||
|
|
||
7 years ago
|
it('return next state for CONSOLE_SHOW_INFO', () => {
|
||
|
let action = { type: actions.CONSOLE_SHOW_INFO, text: 'an info' };
|
||
|
let state = reducer({}, action);
|
||
|
expect(state).to.have.property('mode', 'info');
|
||
|
expect(state).to.have.property('messageText', 'an info');
|
||
|
});
|
||
|
|
||
7 years ago
|
it('return next state for CONSOLE_SHOW_ERROR', () => {
|
||
|
let action = { type: actions.CONSOLE_SHOW_ERROR, text: 'an error' };
|
||
7 years ago
|
let state = reducer({}, action);
|
||
7 years ago
|
expect(state).to.have.property('mode', 'error');
|
||
|
expect(state).to.have.property('messageText', 'an error');
|
||
7 years ago
|
});
|
||
|
|
||
7 years ago
|
it('return next state for CONSOLE_HIDE_COMMAND', () => {
|
||
|
let action = { type: actions.CONSOLE_HIDE_COMMAND };
|
||
|
let state = reducer({ mode: 'command' }, action);
|
||
|
expect(state).to.have.property('mode', '');
|
||
|
|
||
|
state = reducer({ mode: 'error' }, action);
|
||
|
expect(state).to.have.property('mode', 'error');
|
||
7 years ago
|
});
|
||
7 years ago
|
|
||
7 years ago
|
it('return next state for CONSOLE_SET_CONSOLE_TEXT', () => {
|
||
|
let action = {
|
||
|
type: actions.CONSOLE_SET_CONSOLE_TEXT,
|
||
|
consoleText: 'hello world'
|
||
|
}
|
||
|
let state = reducer({}, action)
|
||
|
|
||
|
expect(state).to.have.property('consoleText', 'hello world');
|
||
|
});
|
||
|
|
||
7 years ago
|
it ('return next state for CONSOLE_SET_COMPLETIONS', () => {
|
||
|
let state = {
|
||
6 years ago
|
select: 0,
|
||
7 years ago
|
completions: [],
|
||
|
}
|
||
|
let action = {
|
||
|
type: actions.CONSOLE_SET_COMPLETIONS,
|
||
|
completions: [{
|
||
|
name: 'Apple',
|
||
|
items: [1, 2, 3]
|
||
|
}, {
|
||
|
name: 'Banana',
|
||
|
items: [4, 5, 6]
|
||
|
}]
|
||
|
}
|
||
7 years ago
|
state = reducer(state, action);
|
||
7 years ago
|
expect(state).to.have.property('completions', action.completions);
|
||
6 years ago
|
expect(state).to.have.property('select', -1);
|
||
7 years ago
|
});
|
||
|
|
||
|
it ('return next state for CONSOLE_COMPLETION_NEXT', () => {
|
||
|
let action = { type: actions.CONSOLE_COMPLETION_NEXT };
|
||
|
let state = {
|
||
6 years ago
|
select: -1,
|
||
7 years ago
|
completions: [{
|
||
|
name: 'Apple',
|
||
|
items: [1, 2]
|
||
|
}, {
|
||
|
name: 'Banana',
|
||
|
items: [3]
|
||
|
}]
|
||
|
};
|
||
|
|
||
7 years ago
|
state = reducer(state, action);
|
||
6 years ago
|
expect(state).to.have.property('select', 0);
|
||
7 years ago
|
|
||
7 years ago
|
state = reducer(state, action);
|
||
6 years ago
|
expect(state).to.have.property('select', 1);
|
||
7 years ago
|
|
||
7 years ago
|
state = reducer(state, action);
|
||
6 years ago
|
expect(state).to.have.property('select', 2);
|
||
|
|
||
7 years ago
|
state = reducer(state, action);
|
||
6 years ago
|
expect(state).to.have.property('select', -1);
|
||
7 years ago
|
});
|
||
|
|
||
|
it ('return next state for CONSOLE_COMPLETION_PREV', () => {
|
||
|
let action = { type: actions.CONSOLE_COMPLETION_PREV };
|
||
|
let state = {
|
||
6 years ago
|
select: -1,
|
||
7 years ago
|
completions: [{
|
||
|
name: 'Apple',
|
||
|
items: [1, 2]
|
||
|
}, {
|
||
|
name: 'Banana',
|
||
|
items: [3]
|
||
|
}]
|
||
|
};
|
||
|
|
||
7 years ago
|
state = reducer(state, action);
|
||
6 years ago
|
expect(state).to.have.property('select', 2);
|
||
7 years ago
|
|
||
7 years ago
|
state = reducer(state, action);
|
||
6 years ago
|
expect(state).to.have.property('select', 1);
|
||
7 years ago
|
|
||
7 years ago
|
state = reducer(state, action);
|
||
6 years ago
|
expect(state).to.have.property('select', 0);
|
||
|
|
||
7 years ago
|
state = reducer(state, action);
|
||
6 years ago
|
expect(state).to.have.property('select', -1);
|
||
7 years ago
|
});
|
||
7 years ago
|
});
|