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


TypeScript MockStoreEnhanced.getState方法代碼示例

本文整理匯總了TypeScript中redux-mock-store.MockStoreEnhanced.getState方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript MockStoreEnhanced.getState方法的具體用法?TypeScript MockStoreEnhanced.getState怎麽用?TypeScript MockStoreEnhanced.getState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在redux-mock-store.MockStoreEnhanced的用法示例。


在下文中一共展示了MockStoreEnhanced.getState方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

    test('success', async () => {
      store = mockStore({
        ...initialState,
        catalog: {
          ...catalogInitialState,
          searchResults: ['a', 'b', 'c'],
          apiKey: 'a',
        },
      }) as any

      await store.dispatch(Catalog.serialize() as any)

      const state = store.getState()

      expect(sessionStorage.setItem).toHaveBeenCalledTimes(2)
      expect(sessionStorage.setItem).toHaveBeenCalledWith('searchCriteria', JSON.stringify(state.catalog.searchCriteria))
      expect(sessionStorage.setItem).toHaveBeenCalledWith('searchResults', JSON.stringify(state.catalog.searchResults))

      expect(localStorage.setItem).toHaveBeenCalledTimes(1)
      expect(localStorage.setItem).toHaveBeenCalledWith('catalog_apiKey', state.catalog.apiKey)

      expect(store.getActions()).toEqual([
        { type: CatalogActions.Serialized.type },
      ])
    })
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:25,代碼來源:catalogActions.test.ts

示例2: test

    test('success', async () => {
      await store.dispatch(Algorithms.serialize() as any)

      expect(sessionStorage.setItem).toHaveBeenCalledTimes(1)
      expect(sessionStorage.setItem).toHaveBeenCalledWith(
        'algorithms_records',
        JSON.stringify(store.getState().algorithms.records),
      )

      expect(store.getActions()).toEqual([
        { type: AlgorithmsActions.Serialized.type },
      ])
    })
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:13,代碼來源:algorithmsActions.test.ts

示例3: test

    test('success', async () => {
      await store.dispatch(ApiStatus.serialize() as any)

      const state = store.getState()

      expect(sessionStorage.setItem).toHaveBeenCalledTimes(2)
      expect(sessionStorage.setItem).toHaveBeenCalledWith(
        'geoserver',
        JSON.stringify(state.apiStatus.geoserver),
      )
      expect(sessionStorage.setItem).toHaveBeenCalledWith(
        'enabled_platforms_records',
        JSON.stringify(state.apiStatus.enabledPlatforms),
      )

      expect(store.getActions()).toEqual([
        { type: ApiStatusActions.Serialized.type },
      ])
    })
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:19,代碼來源:apiStatusActions.test.ts


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