本文整理汇总了TypeScript中app/shared/reducers/action-type.util.REQUEST方法的典型用法代码示例。如果您正苦于以下问题:TypeScript util.REQUEST方法的具体用法?TypeScript util.REQUEST怎么用?TypeScript util.REQUEST使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app/shared/reducers/action-type.util
的用法示例。
在下文中一共展示了util.REQUEST方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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;
}
};
示例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: it
it('should detect a request', () => {
const toTest = account(undefined, { type: REQUEST(ACTION_TYPES.UPDATE_ACCOUNT) });
expect(toTest).toMatchObject({
updateSuccess: false,
updateFailure: false,
loading: true
});
});
示例4: it
it('should set state to updating', () => {
testMultipleTypes(
[
REQUEST(ACTION_TYPES.CREATE_FLOCKRELATION),
REQUEST(ACTION_TYPES.UPDATE_FLOCKRELATION),
REQUEST(ACTION_TYPES.DELETE_FLOCKRELATION)
],
{},
state => {
expect(state).toMatchObject({
errorMessage: null,
updateSuccess: false,
updating: true
});
}
);
});
示例5: it
it('dispatches FETCH_LOGS_CHANGE_LEVEL_PENDING and FETCH_LOGS_CHANGE_LEVEL_FULFILLED actions', async () => {
const expectedActions = [
{
type: REQUEST(ACTION_TYPES.FETCH_LOGS_CHANGE_LEVEL)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_LOGS_CHANGE_LEVEL),
payload: resolvedObject
},
{
type: REQUEST(ACTION_TYPES.FETCH_LOGS)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_LOGS),
payload: resolvedObject
}
];
await store.dispatch(changeLogLevel('ROOT', 'DEBUG')).then(() => expect(store.getActions()).toEqual(expectedActions));
});
示例6: it
it('dispatches DELETE_USER_PENDING and DELETE_USER_FULFILLED actions', async () => {
const expectedActions = [
{
type: REQUEST(ACTION_TYPES.DELETE_USER)
},
{
type: SUCCESS(ACTION_TYPES.DELETE_USER),
payload: resolvedObject
},
{
type: REQUEST(ACTION_TYPES.FETCH_USERS)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_USERS),
payload: resolvedObject
}
];
await store.dispatch(deleteUser('admin')).then(() => expect(store.getActions()).toEqual(expectedActions));
});
示例7: it
it('dispatches ACTION_TYPES.CREATE_DIALOGUE actions', async () => {
const expectedActions = [
{
type: REQUEST(ACTION_TYPES.CREATE_DIALOGUE)
},
{
type: SUCCESS(ACTION_TYPES.CREATE_DIALOGUE),
payload: resolvedObject
},
{
type: REQUEST(ACTION_TYPES.FETCH_DIALOGUE_LIST)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_DIALOGUE_LIST),
payload: resolvedObject
}
];
await store.dispatch(createEntity({ id: 1 })).then(() => expect(store.getActions()).toEqual(expectedActions));
});
示例8: it
it('dispatches ACTION_TYPES.UPDATE_CUSTOMER actions', async () => {
const expectedActions = [
{
type: REQUEST(ACTION_TYPES.UPDATE_CUSTOMER)
},
{
type: SUCCESS(ACTION_TYPES.UPDATE_CUSTOMER),
payload: resolvedObject
},
{
type: REQUEST(ACTION_TYPES.FETCH_CUSTOMER_LIST)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_CUSTOMER_LIST),
payload: resolvedObject
}
];
await store.dispatch(updateEntity({ id: 1 })).then(() => expect(store.getActions()).toEqual(expectedActions));
});
示例9: it
it('dispatches ACTION_TYPES.FETCH_HISTORYMESSAGE actions', async () => {
const expectedActions = [
{
type: REQUEST(ACTION_TYPES.FETCH_HISTORYMESSAGE)
},
{
type: SUCCESS(ACTION_TYPES.FETCH_HISTORYMESSAGE),
payload: resolvedObject
}
];
await store.dispatch(getEntity(42666)).then(() => expect(store.getActions()).toEqual(expectedActions));
});