本文整理汇总了TypeScript中moxios.stubRequest函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stubRequest函数的具体用法?TypeScript stubRequest怎么用?TypeScript stubRequest使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stubRequest函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should respond with 200 on fixed/broken", async () => {
try {
moxios.stubRequest(
`${circleAPI}/project/github/ft-interactive/` +
`ft-ig-github-project-manager/23?circle-token=llama`,
{
status: 200,
response: TestCircleBuildPayload
}
);
moxios.stubRequest(`${slackAPI}/testing`, {
status: 200,
responseText: "ok"
});
sig = signBlob("llama", JSON.stringify(TestStatusEvent));
const server = app.listen(2222);
return request(server)
.post("/github")
.set("X-Hub-Signature", sig)
.set("X-Github-Event", "status")
.set("X-Github-Delivery", "abc456")
.send(TestStatusEvent)
.expect(200)
.then(() => server.close());
} catch (e) {
console.error(e);
}
});
示例2: it
it('should dispatch SIGNIN_FAILURE on failed signin', () => {
const user = {
email: 'test-user@andela.com',
};
moxios.stubRequest('/api/v1/auth/register/', {
status: 401,
response: {
message: 'Invalid Token',
},
});
const expectedActions = [
{payload: undefined,
type: 'SIGNIN_FAILURE',
},
];
const store = mockStore();
const gAuth = gapi.auth2.getAuthInstance();
return store.dispatch(actions.signIn(gAuth.currentUser.get()))
.then(() => {
expect(store.getActions()).toEqual(expectedActions);
});
});
示例3: it
it('should stub requests RegExp', (done) => {
moxios.stubRequest(/\/users\/\d*/, {
status: 200,
response: USER_FRED
});
axios.get('/users/12345').then(onFulfilled);
moxios.wait(() => {
let response = onFulfilled.getCall(0).args[0];
deepEqual(response.data, USER_FRED);
done();
});
});