本文整理汇总了TypeScript中moxios.requests类的典型用法代码示例。如果您正苦于以下问题:TypeScript requests类的具体用法?TypeScript requests怎么用?TypeScript requests使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了requests类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: done
moxios.wait(async () => {
const results = await resultsPromise;
const firstRequest = moxios.requests.at(0);
const secondRequest = moxios.requests.at(1);
// @TODO uncomment after DefinitelyTyped#20466 fixed
// JSON.parse(firstRequest.config.data).name.should.equal('HERPA');
// JSON.parse(firstRequest.config.data).value.should.equal('derpa');
// JSON.parse(secondRequest.config.data).name.should.equal('LLAMA');
// JSON.parse(secondRequest.config.data).value.should.equal('duck');
done();
});
示例2: equal
moxios.wait(() => {
let response = onFulfilled.getCall(0).args[0];
equal(response.status, 204);
let request = moxios.requests.get('PUT', '/users/12345');
notEqual(request, undefined);
done();
});
示例3: expect
.wait(() => {
let request = moxios.requests.mostRecent();
request
.respondWith({ status: 200, response })
.then(function () {
expect(toast.success)
.toHaveBeenCalledWith("Regimen saved.");
done();
});
});
示例4: expect
moxios.wait(function () {
let request = moxios.requests.mostRecent();
request.respondWith({
status: 200,
response: {}
}).then(function (resp) {
expect(resp.config.url).toContain("api/users");
expect(resp.config.method).toBe("delete");
done();
});
});
示例5: expect
moxios.wait(function () {
const request = moxios.requests.mostRecent();
request.respondWith({
status: 422,
response: {}
}).then(resp => {
expect(window.alert).not.toHaveBeenCalled();
expect(toastErrors).toHaveBeenCalled();
expect(resp.config.url).toContain("api/device/reset");
done();
});
});