本文整理汇总了TypeScript中fetch-mock.lastOptions函数的典型用法代码示例。如果您正苦于以下问题:TypeScript lastOptions函数的具体用法?TypeScript lastOptions怎么用?TypeScript lastOptions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lastOptions函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: should
return this.api.logout('foo', 'bar').then(() => {
opts = fetchMock.lastOptions('logout')
should(opts.headers.has('sessionID')).be.ok()
this.api.login('foo', 'bar')
opts = fetchMock.lastOptions('login')
should(opts.headers.has('sessionID')).not.be.ok()
})
示例2: expect
.catch((res: Response) => {
if (fetchMock.lastOptions()) {
expect(fetchMock.lastOptions().method).to.equal(httpMethod)
}
expect(res.status).to.deep.equal(responseData.status)
fetchMock.restore()
})
示例3: it
it('should have accept header set on application/json', () => {
fetchMock.get('/some/url', 200);
createXhr().ajax('/some/url');
expect(getHeaderValue(fetchMock.lastOptions(), 'Accept')).toBe('application/json; charset=utf-8');
});
示例4: it
it('should use supplied Content-Type', async () => {
fetchMock.get('*', {});
await kfetch({ pathname: 'my/path', headers: { 'Content-Type': 'CustomContentType' } });
expect(fetchMock.lastOptions('*').headers).toMatchObject({
'Content-Type': 'CustomContentType',
});
});
示例5: getRequestBody
function getRequestBody() {
const request = fetchMock.lastOptions();
if (isRequestInit(request) && request.body) {
return JSON.parse(request.body.toString());
}
throw new Error('Unexpected type of request');
}
示例6: createMd
return createMd().getObjects(projectId, uris).then((result: any) => {
const request = fetchMock.lastOptions(getUri) as RequestInit;
expect(JSON.parse(request.body!.toString())).toEqual({
get: {
items: uris
}
});
expect(result).toEqual(expectedResponses);
});