MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / getMocks

Function getMocks

functions/slack/test/unit.test.js:81–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79};
80
81const getMocks = () => {
82 const req = {
83 headers: {},
84 query: {},
85 body: {},
86 get: function (header) {
87 return this.headers[header];
88 },
89 };
90 sinon.spy(req, 'get');
91 const res = {
92 headers: {},
93 send: sinon.stub().returnsThis(),
94 json: sinon.stub().returnsThis(),
95 end: sinon.stub().returnsThis(),
96 status: function (statusCode) {
97 this.statusCode = statusCode;
98 return this;
99 },
100 set: function (header, value) {
101 this.headers[header] = value;
102 return this;
103 },
104 };
105 sinon.spy(res, 'status');
106 sinon.spy(res, 'set');
107 return {
108 req: req,
109 res: res,
110 };
111};
112
113const stubConsole = function () {
114 sinon.stub(console, 'error');

Callers 1

unit.test.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected