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


TypeScript moxios.stubRequest函數代碼示例

本文整理匯總了TypeScript中moxios.stubRequest函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript stubRequest函數的具體用法?TypeScript stubRequest怎麽用?TypeScript stubRequest使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: it

    it("should respond with 200 on fixed/broken", async () => {
      try {
        moxios.stubRequest(
          `${circleAPI}/project/github/ft-interactive/` +
            `ft-ig-github-project-manager/23?circle-token=llama`,
          {
            status: 200,
            response: TestCircleBuildPayload
          }
        );

        moxios.stubRequest(`${slackAPI}/testing`, {
          status: 200,
          responseText: "ok"
        });

        sig = signBlob("llama", JSON.stringify(TestStatusEvent));

        const server = app.listen(2222);
        return request(server)
          .post("/github")
          .set("X-Hub-Signature", sig)
          .set("X-Github-Event", "status")
          .set("X-Github-Delivery", "abc456")
          .send(TestStatusEvent)
          .expect(200)
          .then(() => server.close());
      } catch (e) {
        console.error(e);
      }
    });
開發者ID:ft-interactive,項目名稱:ft-ig-github-project-manager,代碼行數:31,代碼來源:e2e.spec.ts

示例2: it

  it('should dispatch SIGNIN_FAILURE on failed signin', () => {
    const user = {
      email: 'test-user@andela.com',
    };

    moxios.stubRequest('/api/v1/auth/register/', {
      status: 401,
      response: {
        message: 'Invalid Token',
      },
    });

    const expectedActions = [
      {payload: undefined,
       type: 'SIGNIN_FAILURE',
      },
    ];

    const store = mockStore();

    const gAuth = gapi.auth2.getAuthInstance();

    return store.dispatch(actions.signIn(gAuth.currentUser.get()))
      .then(() => {
        expect(store.getActions()).toEqual(expectedActions);
      });
  });
開發者ID:andela-sjames,項目名稱:Django-ReactJS-Library-App,代碼行數:27,代碼來源:authActions.spec.ts

示例3: it

        it('should stub requests RegExp', (done) => {
            moxios.stubRequest(/\/users\/\d*/, {
                status: 200,
                response: USER_FRED
            });

            axios.get('/users/12345').then(onFulfilled);

            moxios.wait(() => {
                let response = onFulfilled.getCall(0).args[0];
                deepEqual(response.data, USER_FRED);
                done();
            });
        });
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:14,代碼來源:moxios-tests.ts


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