本文整理汇总了TypeScript中app/shared/reducers/action-type.util.FAILURE方法的典型用法代码示例。如果您正苦于以下问题:TypeScript util.FAILURE方法的具体用法?TypeScript util.FAILURE怎么用?TypeScript util.FAILURE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app/shared/reducers/action-type.util
的用法示例。
在下文中一共展示了util.FAILURE方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: default
// Reducer
export default (state: PasswordResetState = initialState, action): PasswordResetState => {
switch (action.type) {
case REQUEST(ACTION_TYPES.RESET_PASSWORD_FINISH):
case REQUEST(ACTION_TYPES.RESET_PASSWORD_INIT):
return {
...state,
loading: true
};
case FAILURE(ACTION_TYPES.RESET_PASSWORD_FINISH):
case FAILURE(ACTION_TYPES.RESET_PASSWORD_INIT):
return {
...initialState,
loading: false,
resetPasswordFailure: true
};
case SUCCESS(ACTION_TYPES.RESET_PASSWORD_FINISH):
case SUCCESS(ACTION_TYPES.RESET_PASSWORD_INIT):
return {
...initialState,
loading: false,
resetPasswordSuccess: true
};
case ACTION_TYPES.RESET:
return {
...initialState
};
default:
return state;
}
};
示例2: default
// Reducer
export default (state: RegisterState = initialState, action): RegisterState => {
switch (action.type) {
case REQUEST(ACTION_TYPES.CREATE_ACCOUNT):
return {
...state,
loading: true
};
case FAILURE(ACTION_TYPES.CREATE_ACCOUNT):
return {
...initialState,
registrationFailure: true,
errorMessage: action.payload.response.data.errorKey
};
case SUCCESS(ACTION_TYPES.CREATE_ACCOUNT):
return {
...initialState,
registrationSuccess: true
};
case ACTION_TYPES.RESET:
return {
...initialState
};
default:
return state;
}
};
示例3: default
// Reducer
export default (state: SettingsState = initialState, action): SettingsState => {
switch (action.type) {
case REQUEST(ACTION_TYPES.UPDATE_ACCOUNT):
return {
...state,
errorMessage: null,
updateSuccess: false,
loading: true
};
case FAILURE(ACTION_TYPES.UPDATE_ACCOUNT):
return {
...state,
loading: false,
updateSuccess: false,
updateFailure: true
};
case SUCCESS(ACTION_TYPES.UPDATE_ACCOUNT):
return {
...state,
loading: false,
updateSuccess: true,
updateFailure: false
};
case ACTION_TYPES.RESET:
return {
...initialState
};
default:
return state;
}
};
示例4: it
it('should detect a failure', () => {
const toTest = account(undefined, { type: FAILURE(ACTION_TYPES.UPDATE_ACCOUNT) });
expect(toTest).toMatchObject({
updateSuccess: false,
updateFailure: true,
loading: false
});
});
示例5: it
it('should set a message in errorMessage', () => {
testMultipleTypes(
[
FAILURE(ACTION_TYPES.FETCH_FLOCKRELATION_LIST),
FAILURE(ACTION_TYPES.FETCH_FLOCKRELATION),
FAILURE(ACTION_TYPES.CREATE_FLOCKRELATION),
FAILURE(ACTION_TYPES.UPDATE_FLOCKRELATION),
FAILURE(ACTION_TYPES.DELETE_FLOCKRELATION)
],
'error message',
state => {
expect(state).toMatchObject({
errorMessage: 'error message',
updateSuccess: false,
updating: false
});
}
);
});
示例6: it
it('should detect a failure on login', () => {
const payload = 'Something happened.';
const toTest = authentication(undefined, { type: FAILURE(ACTION_TYPES.LOGIN), payload });
expect(toTest).toMatchObject({
errorMessage: payload,
showModalLogin: true,
loginError: true
});
expect(isAccountEmpty(toTest));
});
示例7: it
it('should handle CREATE_ACCOUNT failure', () => {
const payload = { response: { data: { errorKey: 'fake error' } } };
expect(
register(undefined, {
type: FAILURE(ACTION_TYPES.CREATE_ACCOUNT),
payload
})
).toEqual({
...initialState,
registrationFailure: true,
errorMessage: payload.response.data.errorKey
});
});
示例8: it
it('should set state to failed and put an error message in errorMessage', () => {
testMultipleTypes(
[
FAILURE(ACTION_TYPES.FETCH_GATEWAY_ROUTE),
FAILURE(ACTION_TYPES.FETCH_LOGS),
FAILURE(ACTION_TYPES.FETCH_HEALTH),
FAILURE(ACTION_TYPES.FETCH_METRICS),
FAILURE(ACTION_TYPES.FETCH_THREAD_DUMP),
FAILURE(ACTION_TYPES.FETCH_CONFIGURATIONS),
FAILURE(ACTION_TYPES.FETCH_ENV),
FAILURE(ACTION_TYPES.FETCH_AUDITS)
],
'something happened',
state => {
expect(state).toMatchObject({
loading: false,
errorMessage: 'something happened'
});
}
);
});
示例9: default
export default (state: SettingsState = initialState, action): SettingsState => {
switch (action.type) {
case ACTION_TYPES.SAVE:
// localStorage的值与state必须保持一致所以写在这里
window.localStorage.setItem('settings', JSON.stringify({
...state,
...action.payload
}));
return {
...state,
...action.payload
};
case REQUEST(ACTION_TYPES.UPDATE_ACCOUNT):
return {
...state,
errorMessage: null,
updateSuccess: false,
loading: true
};
case FAILURE(ACTION_TYPES.UPDATE_ACCOUNT):
return {
...state,
loading: false,
updateSuccess: false,
updateFailure: true
};
case SUCCESS(ACTION_TYPES.UPDATE_ACCOUNT):
return {
...state,
loading: false,
updateSuccess: true,
updateFailure: false
};
case ACTION_TYPES.RESET:
return {
...initialState
};
default:
return state;
}
};