本文整理汇总了TypeScript中node-mocks-http.createResponse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createResponse函数的具体用法?TypeScript createResponse怎么用?TypeScript createResponse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createResponse函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(() => {
req = (httpMocks.createRequest() as any) as CancanRequest;
res = httpMocks.createResponse();
next = () => {};
resourceLoader = cancan2.loadAndAuthorizeResource('Book');
req.user = user1;
});
示例2: beforeEach
beforeEach(function() {
// // use it if you only want to spy if "res.json" is calledOnce
// req = {
// params: {
// id: "1"
// }
// };
req = httpMocks.createRequest({
// method: 'GET',
// url: '/user/42',
params: {
id: 123
}
});
// use this if userServiceStub returns data synchronously
res = httpMocks.createResponse();
// // use a simple request if you don't want to test the result returned from spied service
// res = {
// json: sinon.spy()
// };
// // use it if userServiceStub returns data async
// res = httpMocks.createResponse({
// eventEmitter: require("events").EventEmitter
// });
userServiceStub = {
default: {
getById: function (id, cb) {
cb(null, { name: "aaa_" + id });
// // if you want to simulate an async mode
// setTimeout(function(){
// cb(null, { id: id, name: "aaa" });
// }, 1000);
},
getAll: function (cb) {
cb(null, [{ name: "aaa" }]);
// // if you want to simulate an async mode
// setTimeout(function(){
// cb(null, { id: id, name: "aaa" });
// }, 1000);
}
}
};
userController = proxyquire("./user.controller", {
"./user.service": userServiceStub
}).default;
});
示例3: beforeEach
beforeEach(() => {
req = (httpMocks.createRequest() as any) as CancanRequest;
res = httpMocks.createResponse();
applyResourcefulCancan(req, res, next);
});
示例4: beforeEach
beforeEach(() => {
req = (httpMocks.createRequest() as any) as CancanRequest;
res = httpMocks.createResponse();
});
示例5: beforeEach
beforeEach(() => {
res = mocks.createResponse();
})