本文整理汇总了TypeScript中app/shared/reducers/action-type.util类的典型用法代码示例。如果您正苦于以下问题:TypeScript util类的具体用法?TypeScript util怎么用?TypeScript util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了util类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should return the right payload in dev with swagger enabled', () => {
const payload = {
data: {
'display-ribbon-on-profiles': 'awesome ribbon stuff',
activeProfiles: ['swagger', 'dev']
}
};
expect(profile(undefined, { type: SUCCESS(ACTION_TYPES.GET_PROFILE), payload })).toEqual({
ribbonEnv: 'awesome ribbon stuff',
inProduction: false,
isSwaggerEnabled: true
});
});
开发者ID:gjik911,项目名称:git_01,代码行数:14,代码来源:application-profile.spec.ts
示例2: it
it('should fetch all entities', () => {
const payload = { data: [{ 1: 'fake1' }, { 2: 'fake2' }], headers: { 'x-total-count': 123 } };
expect(
reducer(undefined, {
type: SUCCESS(ACTION_TYPES.FETCH_HISTORYMESSAGE_LIST),
payload
})
).toEqual({
...initialState,
loading: false,
totalItems: payload.headers['x-total-count'],
entities: payload.data
});
});
开发者ID:gjik911,项目名称:git_01,代码行数:14,代码来源:history-message-reducer.spec.ts
示例3: default
/**
* 保持 reducer 纯净非常重要。永远不要在 reducer 里做这些操作:
* 修改传入参数;
* 执行有副作用的操作,如 API 请求和路由跳转;
* 调用非纯函数,如 Date.now() 或 Math.random()。
*/
export default (state: ApplicationProfileState = initialState, action): ApplicationProfileState => {
switch (action.type) {
case SUCCESS(ACTION_TYPES.GET_PROFILE):
const { data } = action.payload;
return {
...state,
ribbonEnv: data['display-ribbon-on-profiles'],
inProduction: data.activeProfiles.includes('prod'),
isSwaggerEnabled: data.activeProfiles.includes('swagger')
};
default:
return state;
}
};
开发者ID:gjik911,项目名称:git_01,代码行数:20,代码来源:application-profile.ts
示例4: it
it('should create/update entity', () => {
const payload = { data: 'fake payload' };
expect(
reducer(undefined, {
type: SUCCESS(ACTION_TYPES.CREATE_CURRENTMESSAGE),
payload
})
).toEqual({
...initialState,
updating: false,
updateSuccess: true,
entity: payload.data
});
});
开发者ID:gjik911,项目名称:git_01,代码行数:14,代码来源:current-message-reducer.spec.ts
示例5: default
// Reducer
export default (state: ActivateState = initialState, action): ActivateState => {
switch (action.type) {
case REQUEST(ACTION_TYPES.ACTIVATE_ACCOUNT):
return {
...state
};
case FAILURE(ACTION_TYPES.ACTIVATE_ACCOUNT):
return {
...state,
activationFailure: true
};
case SUCCESS(ACTION_TYPES.ACTIVATE_ACCOUNT):
return {
...state,
activationSuccess: true
};
case ACTION_TYPES.RESET:
return {
...initialState
};
default:
return state;
}
};
开发者ID:gjik911,项目名称:git_01,代码行数:25,代码来源:activate.reducer.ts
示例6: it
it('should set state to loading', () => {
testMultipleTypes(
[
REQUEST(ACTION_TYPES.FETCH_GATEWAY_ROUTE),
REQUEST(ACTION_TYPES.FETCH_LOGS),
REQUEST(ACTION_TYPES.FETCH_HEALTH),
REQUEST(ACTION_TYPES.FETCH_METRICS),
REQUEST(ACTION_TYPES.FETCH_THREAD_DUMP),
REQUEST(ACTION_TYPES.FETCH_CONFIGURATIONS),
REQUEST(ACTION_TYPES.FETCH_ENV),
REQUEST(ACTION_TYPES.FETCH_AUDITS)
],
{},
state => {
expect(state).toMatchObject({
errorMessage: null,
loading: true
});
}
);
});
开发者ID:gjik911,项目名称:git_01,代码行数:21,代码来源:administration.reducer.spec.ts
示例7: it
it('should set state to failed and put an error message in errorMessage', () => {
testMultipleTypes(
[
FAILURE(ACTION_TYPES.FETCH_USERS),
FAILURE(ACTION_TYPES.FETCH_USER),
FAILURE(ACTION_TYPES.FETCH_ROLES),
FAILURE(ACTION_TYPES.CREATE_USER),
FAILURE(ACTION_TYPES.UPDATE_USER),
FAILURE(ACTION_TYPES.DELETE_USER)
],
'something happened',
state => {
expect(state).toMatchObject({
loading: false,
updating: false,
updateSuccess: false,
errorMessage: 'something happened'
});
}
);
});
开发者ID:gjik911,项目名称:git_01,代码行数:21,代码来源:user-management.reducer.spec.ts
示例8: it
it('should detect a success', () => {
expect(activate(undefined, { type: SUCCESS(ACTION_TYPES.ACTIVATE_ACCOUNT) })).toMatchObject({
activationSuccess: true,
activationFailure: false
});
});
开发者ID:gjik911,项目名称:git_01,代码行数:6,代码来源:activate.reducer.spec.ts
示例9: default
export default (state: CustomerFlockState = initialState, action): CustomerFlockState => {
switch (action.type) {
case REQUEST(ACTION_TYPES.SEARCH_CUSTOMERFLOCKS):
case REQUEST(ACTION_TYPES.FETCH_CUSTOMERFLOCK_LIST):
case REQUEST(ACTION_TYPES.FETCH_CUSTOMERFLOCK):
return {
...state,
errorMessage: null,
updateSuccess: false,
loading: true
};
case REQUEST(ACTION_TYPES.CREATE_CUSTOMERFLOCK):
case REQUEST(ACTION_TYPES.UPDATE_CUSTOMERFLOCK):
case REQUEST(ACTION_TYPES.DELETE_CUSTOMERFLOCK):
return {
...state,
errorMessage: null,
updateSuccess: false,
updating: true
};
case FAILURE(ACTION_TYPES.SEARCH_CUSTOMERFLOCKS):
case FAILURE(ACTION_TYPES.FETCH_CUSTOMERFLOCK_LIST):
case FAILURE(ACTION_TYPES.FETCH_CUSTOMERFLOCK):
case FAILURE(ACTION_TYPES.CREATE_CUSTOMERFLOCK):
case FAILURE(ACTION_TYPES.UPDATE_CUSTOMERFLOCK):
case FAILURE(ACTION_TYPES.DELETE_CUSTOMERFLOCK):
return {
...state,
loading: false,
updating: false,
updateSuccess: false,
errorMessage: action.payload
};
case SUCCESS(ACTION_TYPES.SEARCH_CUSTOMERFLOCKS):
return {
...state,
loading: false,
entities: action.payload.data
};
case SUCCESS(ACTION_TYPES.FETCH_CUSTOMERFLOCK_LIST):
return {
...state,
loading: false,
totalItems: action.payload.headers['x-total-count'],
entities: action.payload.data
};
case SUCCESS(ACTION_TYPES.FETCH_CUSTOMERFLOCK):
return {
...state,
loading: false,
entity: action.payload.data
};
case SUCCESS(ACTION_TYPES.CREATE_CUSTOMERFLOCK):
case SUCCESS(ACTION_TYPES.UPDATE_CUSTOMERFLOCK):
return {
...state,
updating: false,
updateSuccess: true,
entity: action.payload.data
};
case SUCCESS(ACTION_TYPES.DELETE_CUSTOMERFLOCK):
return {
...state,
updating: false,
updateSuccess: true,
entity: {}
};
case ACTION_TYPES.RESET:
return {
...initialState
};
default:
return state;
}
};
开发者ID:gjik911,项目名称:git_01,代码行数:75,代码来源:customer-flock.reducer.ts
注:本文中的app/shared/reducers/action-type.util类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论