当前位置: 首页>>代码示例>>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;未经允许,请勿转载。