當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript action-type.util類代碼示例

本文整理匯總了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;未經允許,請勿轉載。