本文整理匯總了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();
});
});