当前位置: 首页>>代码示例>>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;未经允许,请勿转载。