UNPKG

jest-mock-req-res

Version:

Jest mocks for Express Request and Response objects. Inspired by mock-req-res.

3 lines (2 loc) 1.57 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).jestMockReqRes={})}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}e.mockRequest=function(e){var n=jest.fn();return t({app:{},baseUrl:"",body:{},cookies:{},fresh:!0,hostname:"",ip:"127.0.0.1",ips:[],method:"",originalUrl:"",params:{},path:"",protocol:"https",query:{},route:{},secure:!0,signedCookies:{},stale:!1,subdomains:[],xhr:!0,accepts:jest.fn(),acceptsCharsets:jest.fn(),acceptsEncodings:jest.fn(),acceptsLanguages:jest.fn(),get:n,header:n,is:jest.fn(),range:jest.fn()},e)},e.mockResponse=function(e){var n=jest.fn().mockReturnThis(),s=jest.fn().mockReturnThis();return t({app:{},headersSent:!1,locals:{},append:jest.fn().mockReturnThis(),attachment:jest.fn().mockReturnThis(),clearCookie:jest.fn().mockReturnThis(),contentType:s,cookie:jest.fn().mockReturnThis(),download:jest.fn(),end:jest.fn(),format:jest.fn().mockReturnThis(),get:jest.fn(),header:n,json:jest.fn().mockReturnThis(),jsonp:jest.fn().mockReturnThis(),links:jest.fn().mockReturnThis(),location:jest.fn().mockReturnThis(),redirect:jest.fn(),render:jest.fn(),send:jest.fn().mockReturnThis(),sendFile:jest.fn(),sendStatus:jest.fn().mockReturnThis(),set:n,status:jest.fn().mockReturnThis(),type:s,vary:jest.fn().mockReturnThis()},e)}}); //# sourceMappingURL=index.umd.js.map