add console actions/reducer tests and fix targets

This commit is contained in:
Shin'ya Ueoka 2017-09-09 22:50:00 +09:00
parent e8056d2a70
commit 7e35d11f65
4 changed files with 88 additions and 8 deletions

View file

@ -1,12 +1,12 @@
import './console.scss';
import Completion from './completion';
import consoleReducer, { defaultState } from '../reducers/console';
import consoleReducer from '../reducers/console';
// TODO consider object-oriented
var prevValue = "";
var completion = null;
var completionOrigin = "";
let state = defaultState;
let state = consoleReducer(undefined, {});
const blurMessage = () => {
return {

View file

@ -1,10 +1,10 @@
import actions from '../actions';
export const defaultState = {
errorText: '',
const defaultState = {
errorShown: false,
commandText: '',
errorText: '',
commandShown: false,
commandText: '',
completions: [],
};
@ -14,7 +14,7 @@ export default function reducer(state = defaultState, action = {}) {
return Object.assign({}, state, {
commandShown: true,
commandText: action.text,
errorShow: false,
errorShown: false,
completions: []
});
case actions.CONSOLE_SET_COMPLETIONS:
@ -23,8 +23,8 @@ export default function reducer(state = defaultState, action = {}) {
});
case actions.CONSOLE_SHOW_ERROR:
return Object.assign({}, state, {
errorText: action.message,
errorShow: true,
errorText: action.text,
errorShown: true,
commandShown: false,
});
case actions.CONSOLE_HIDE: