mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 07:08:10 +00:00
[web] Remove js/ducks/ui/option.js
This commit is contained in:
parent
f465f08c9a
commit
cb73658dd4
@ -1,39 +0,0 @@
|
||||
import reduceOption, * as optionActions from '../../../ducks/ui/option'
|
||||
|
||||
describe('option reducer', () => {
|
||||
|
||||
it('should return the initial state', () => {
|
||||
expect(reduceOption(undefined, {})).toEqual({})
|
||||
})
|
||||
|
||||
let state = undefined
|
||||
it('should handle option update start', () => {
|
||||
state = reduceOption(undefined, {
|
||||
type: optionActions.OPTION_UPDATE_START, option: 'foo', value: 'bar'
|
||||
})
|
||||
expect(state).toEqual({
|
||||
foo: {
|
||||
error: false,
|
||||
isUpdating: true,
|
||||
value: 'bar'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should handle option update success', () => {
|
||||
expect(reduceOption(state, {
|
||||
type: optionActions.OPTION_UPDATE_SUCCESS, option: 'foo'
|
||||
})).toEqual({})
|
||||
})
|
||||
|
||||
it('should handle option update error', () => {
|
||||
expect(reduceOption(undefined, {
|
||||
type: optionActions.OPTION_UPDATE_ERROR, option: 'foo', error: 'errorMsg'
|
||||
})).toEqual({
|
||||
foo: {
|
||||
error: 'errorMsg',
|
||||
isUpdating: false,
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
@ -1,39 +0,0 @@
|
||||
export const OPTION_UPDATE_START = 'UI_OPTION_UPDATE_START'
|
||||
export const OPTION_UPDATE_SUCCESS = 'UI_OPTION_UPDATE_SUCCESS'
|
||||
export const OPTION_UPDATE_ERROR = 'UI_OPTION_UPDATE_ERROR'
|
||||
|
||||
const defaultState = {
|
||||
/* optionName -> {isUpdating, value (client-side), error} */
|
||||
}
|
||||
|
||||
export default function reducer(state = defaultState, action) {
|
||||
switch (action.type) {
|
||||
case OPTION_UPDATE_START:
|
||||
return {
|
||||
...state,
|
||||
[action.option]: {
|
||||
isUpdating: true,
|
||||
value: action.value,
|
||||
error: false,
|
||||
}
|
||||
}
|
||||
|
||||
case OPTION_UPDATE_SUCCESS:
|
||||
let s = {...state}
|
||||
delete s[action.option]
|
||||
return s
|
||||
|
||||
case OPTION_UPDATE_ERROR:
|
||||
return {
|
||||
...state,
|
||||
[action.option]: {
|
||||
...state[action.option],
|
||||
isUpdating: false,
|
||||
error: action.error
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user