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