当前位置: 首页>>代码示例>>TypeScript>>正文


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

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


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

示例1: it

            it('should log out user', () => {
                expect.assertions(1);
                const userId = 'USER_ID';

                fetchMock.mock(
                    '/gdc/account/token',
                    200
                );

                fetchMock.mock(
                    '/gdc/app/account/bootstrap',
                    {
                        status: 200,
                        body: JSON.stringify({
                            bootstrapResource: {
                                accountSetting: {
                                    links: {
                                        self: `/gdc/account/profile/${userId}`
                                    }
                                }
                            }
                        })
                    }
                );

                fetchMock.delete(
                    `/gdc/account/login/${userId}`,
                    200 // should be 204, but see https://github.com/wheresrhys/fetch-mock/issues/36
                );

                return createUser().logout().then((r) => {
                    expect(r && r.response.ok).toBeTruthy();
                });
            });
开发者ID:gooddata,项目名称:gooddata-js,代码行数:34,代码来源:user.test.ts

示例2: it

            it('should delete project', () => {
                const projectId = 'myFakeProjectId';

                fetchMock.delete(
                    `/gdc/projects/${projectId}`,
                    200
                );

                return createProject().deleteProject(projectId).then((r: any) => expect(r.response.ok).toBeTruthy());
            });
开发者ID:gooddata,项目名称:gooddata-js,代码行数:10,代码来源:project.test.ts

示例3:

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);

fetchMock.get("http://test.com", 200, {method: "GET"});
fetchMock.get("http://test.com", 200, {method: "GET", overwriteRoutes: true});
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"});

fetchMock
  .mock("http://test.com", 200)
开发者ID:Dru89,项目名称:DefinitelyTyped,代码行数:31,代码来源:fetch-mock-tests.ts


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