本文整理匯總了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;
}
};