• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fetch-mock.lastUrl函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中fetch-mock.lastUrl函数的典型用法代码示例。如果您正苦于以下问题:TypeScript lastUrl函数的具体用法?TypeScript lastUrl怎么用?TypeScript lastUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了lastUrl函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: expect

 .then(() => {
   expect(fetchMock.calls().matched.length).to.equal(1)
   expect(fetchMock.lastUrl()).to.equal(url)
   expect(fetchMock.lastOptions()).to.deep.equal({
     method: 'get',
     headers: {
       'Accept': 'application/json',
       'Content-Type': 'application/json'
     },
     credentials: 'include'
   })
   fetchMock.restore()
 })
开发者ID:rucky2013,项目名称:teambition-sdk,代码行数:13,代码来源:fetch.ts


示例2:

fetchMock.restore().reset();

(fetchMock.calls().matched[0][1] as RequestInit).body;
fetchMock.calls().unmatched[0][0].toUpperCase();
fetchMock.calls("http://test.com")[0][0].toUpperCase();
(fetchMock.calls("http://test.com")[0][1] as RequestInit).body;

const doneStatus: boolean = fetchMock.done();
const doneStatusArguments: boolean = fetchMock.done("http://test.com");

const calledStatus: boolean = fetchMock.called();
const calledStatusArguments = fetchMock.called("http://test.com");

(fetchMock.lastCall()[1] as RequestInit).body;
const lastUrl: string = fetchMock.lastUrl();
fetchMock.lastOptions();

fetchMock.get("http://test.com", 200);
fetchMock.getOnce("http://test.com", 200);
fetchMock.post("http://test.com", 200);
fetchMock.postOnce("http://test.com", 200);
fetchMock.put("http://test.com", 200);
fetchMock.putOnce("http://test.com", 200);
fetchMock.delete("http://test.com", 200);
fetchMock.deleteOnce("http://test.com", 200);
fetchMock.head("http://test.com", 200);
fetchMock.headOnce("http://test.com", 200);
fetchMock.patch("http://test.com", 200);
fetchMock.patchOnce("http://test.com", 200);
开发者ID:Dru89,项目名称:DefinitelyTyped,代码行数:29,代码来源:fetch-mock-tests.ts


示例3: it

		it('should request POST /batch', function () {
			should(fetchMock.lastUrl()).equal(API_URL + '/attask/api-internal/batch')
			should(fetchMock.lastOptions()).have.property('method', 'POST')
		})
开发者ID:Workfront,项目名称:workfront-api,代码行数:4,代码来源:batch.spec.ts


示例4:

calledStatus = fetchMock.called("http://test.com", {
    method: "GET",
});
calledStatus = fetchMock.called((url: string, opts: fetchMock.MockRequest): boolean => {
    return true;
});
calledStatus = fetchMock.called(fetchMock.MATCHED);
calledStatus = fetchMock.called(fetchMock.UNMATCHED);

let lastCall: fetchMock.MockCall = fetchMock.lastCall();
lastCall = fetchMock.lastCall(/https?:\/\/test.com/, {
    method: "GET",
});
lastCall = fetchMock.lastCall("https://test.com", "GET");

let lastUrl: string = fetchMock.lastUrl();
lastUrl = fetchMock.lastUrl(true);
lastUrl = fetchMock.lastUrl("http://test.com");
lastUrl = fetchMock.lastUrl(/https?:\/\/test.com/);
lastUrl = fetchMock.lastUrl("http://test.com", "GET");
lastUrl = fetchMock.lastUrl("http://test.com", {
    method: "GET",
});
let lastOptions: fetchMock.MockOptions = fetchMock.lastOptions();
lastOptions = fetchMock.lastOptions(true);
lastOptions = fetchMock.lastOptions("http://test.com");
lastOptions = fetchMock.lastOptions(/https?:\/\/test.com/);
lastOptions = fetchMock.lastOptions("http://test.com", "GET");
lastOptions = fetchMock.lastOptions("http://test.com", {
    method: "GET",
});
开发者ID:ferrantejake,项目名称:DefinitelyTyped,代码行数:31,代码来源:fetch-mock-tests.ts


示例5:

    },
    body: {
        a: "b"
    }
});

fetchMock.restore().reset();

(fetchMock.calls().matched[0][1] as RequestInit).body;
fetchMock.calls().unmatched[0][0].toUpperCase();
fetchMock.calls("http://test.com")[0][0].toUpperCase();
(fetchMock.calls("http://test.com")[0][1] as RequestInit).body;

fetchMock.called("http://test.com");

(fetchMock.lastCall()[1] as RequestInit).body;
fetchMock.lastUrl();
fetchMock.lastOptions();

fetchMock.get("http://test.com", 200)
fetchMock.post("http://test.com", 200)
fetchMock.put("http://test.com", 200)
fetchMock.delete("http://test.com", 200)
fetchMock.head("http://test.com", 200)

fetchMock.get("http://test.com", 200, {method: "GET"})
fetchMock.post("http://test.com", 200, {method: "POST"})
fetchMock.put("http://test.com", 200, {method: "PUT"})
fetchMock.delete("http://test.com", 200, {method: "DELETE"})
fetchMock.head("http://test.com", 200, {method: "HEAD"})
开发者ID:Agamnentzar,项目名称:DefinitelyTyped,代码行数:30,代码来源:fetch-mock-tests.ts


示例6: it

 it('should not prepend url with basepath when disabled', async () => {
   fetchMock.get('*', {});
   await kfetch({ pathname: 'my/path' }, { prependBasePath: false });
   expect(fetchMock.lastUrl('*')).toBe('my/path');
 });
开发者ID:gingerwizard,项目名称:kibana,代码行数:5,代码来源:kfetch.test.ts



注:本文中的fetch-mock.lastUrl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fetch-mock.mock函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fetch-mock.lastOptions函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap