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


TypeScript MockStoreEnhanced.dispatch方法代碼示例

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


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

示例1: test

    test('success', async () => {
      await store.dispatch(User.sessionExpired())

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

示例2: test

    test('success', async () => {
      const loc = {
        pathname: 'a',
        search: '?jobId=1&jobId=2&jobId=3',
        hash: 'b',
        selectedFeature: 'c',
      }

      const pushStateSpy = sinon.spy(history, 'pushState')

      await store.dispatch(Route.navigateTo({ loc } as any))

      const href = `${loc.pathname}${loc.search}${loc.hash}`

      expect(pushStateSpy.callCount).toEqual(1)
      expect(pushStateSpy.args[0]).toEqual([null, '', href])

      expect(store.getActions()).toEqual([
        {
          type: RouteActions.Changed.type,
          payload: {
            pathname: loc.pathname,
            search: loc.search,
            hash: loc.hash,
            selectedFeature: loc.selectedFeature,
            href,
            jobIds: ['1', '2', '3'],
          },
        },
      ])

      pushStateSpy.restore()
    })
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:33,代碼來源:routeActions.test.ts

示例3: it

  it('should dispatch error on failure', async () => {
    const error = new Error('The server is on fire');
    mockAxios.request.mockRejectedValueOnce(error);

    const p = store.dispatch(requestAction);
    await expect(p).rejects.toEqual(error);

    expect(mockAxios.request).toBeCalledTimes(1);

    expect(store.getActions()).toMatchObject([
      {
        type: 'TEST_ACTION_REQUEST',
        meta: {
          requestStatus: REQUEST,
        },
      },
      {
        type: 'TEST_ACTION_FAILURE',
        payload: error,
        meta: {
          requestStatus: FAILURE,
        },
      },
    ]);
  });
開發者ID:nusmodifications,項目名稱:nusmods,代碼行數:25,代碼來源:requests-middleware.test.ts

示例4: test

    test('success', async () => {
      await store.dispatch(Tour.end())

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

示例5: test

    test('success', async () => {
      await store.dispatch(Map.clearBbox())

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

示例6: test

    test('success', async () => {
      const mockResponse = {
        geoserver: 'a',
        'enabled-platforms': ['a', 'b'],
      }
      mockAdapter.onGet('/').reply(200, mockResponse)

      await store.dispatch(ApiStatus.fetch() as any)

      expect(clientSpies.get.callCount).toEqual(1)
      expect(clientSpies.get.args[0]).toEqual(['/'])

      expect(store.getActions()).toEqual([
        { type: ApiStatusActions.Fetching.type },
        {
          type: ApiStatusActions.FetchSuccess.type,
          payload: {
            geoserver: {
              wmsUrl: mockResponse.geoserver + '/wms',
            },
            enabledPlatforms: mockResponse['enabled-platforms'],
          },
        },
      ])
    })
開發者ID:venicegeo,項目名稱:bf-ui,代碼行數:25,代碼來源:apiStatusActions.test.ts


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