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


TypeScript util.FAILURE方法代碼示例

本文整理匯總了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;
  }
};
開發者ID:gjik911,項目名稱:git_01,代碼行數:31,代碼來源:password-reset.reducer.ts

示例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;
  }
};
開發者ID:gjik911,項目名稱:git_01,代碼行數:27,代碼來源:register.reducer.ts

示例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;
  }
};
開發者ID:gjik911,項目名稱:git_01,代碼行數:32,代碼來源:settings.reducer.ts

示例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
   });
 });
開發者ID:gjik911,項目名稱:git_01,代碼行數:8,代碼來源:settings.reducer.spec.ts

示例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
       });
     }
   );
 });
開發者ID:gjik911,項目名稱:git_01,代碼行數:19,代碼來源:flock-relation-reducer.spec.ts

示例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));
    });
開發者ID:gjik911,項目名稱:git_01,代碼行數:11,代碼來源:authentication.spec.ts

示例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
   });
 });
開發者ID:gjik911,項目名稱:git_01,代碼行數:13,代碼來源:register.reducer.spec.ts

示例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'
       });
     }
   );
 });
開發者ID:gjik911,項目名稱:git_01,代碼行數:21,代碼來源:administration.reducer.spec.ts

示例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;
    }
};
開發者ID:gjik911,項目名稱:git_01,代碼行數:41,代碼來源:settings.ts


注:本文中的app/shared/reducers/action-type.util.FAILURE方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。