當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript node-mocks-http.createResponse函數代碼示例

本文整理匯總了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;
 });
開發者ID:hanlindev,項目名稱:resourceful-cancan-sequelize,代碼行數:7,代碼來源:load-and-authorize-resource-spec.ts

示例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;
    });
開發者ID:lmaran,項目名稱:logspace,代碼行數:54,代碼來源:user.controller.test.ts

示例3: beforeEach

 beforeEach(() => {
     req = (httpMocks.createRequest() as any) as CancanRequest;
     res = httpMocks.createResponse();
     applyResourcefulCancan(req, res, next);
 });
開發者ID:hanlindev,項目名稱:resourceful-cancan-sequelize,代碼行數:5,代碼來源:resourceful-cancan-spec.ts

示例4: beforeEach

 beforeEach(() => {
     req = (httpMocks.createRequest() as any) as CancanRequest;
     res = httpMocks.createResponse();
 });
開發者ID:hanlindev,項目名稱:resourceful-cancan-sequelize,代碼行數:4,代碼來源:load-resource-spec.ts

示例5: beforeEach

 beforeEach(() => {
     res = mocks.createResponse();
 })
開發者ID:rjmacarthy,項目名稱:express-typescript-starter,代碼行數:3,代碼來源:index.spec.ts


注:本文中的node-mocks-http.createResponse函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。