Add mock request/response classes for testing
This commit is contained in:
parent
014574a545
commit
cae754672e
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
|
||||
var sinon = require('sinon'),
|
||||
spy = sinon.spy,
|
||||
stub = sinon.stub;
|
||||
|
||||
// A mock version of the http.ClientRequest class
|
||||
var MockRequest = module.exports = function MockRequest(opts) {
|
||||
if (opts == null) {
|
||||
opts = {};
|
||||
}
|
||||
|
||||
this.url = "/";
|
||||
|
||||
this.headers = {};
|
||||
|
||||
for (var opt in opts) {
|
||||
this[opt] = opts[opt];
|
||||
}
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
var sinon = require('sinon'),
|
||||
spy = sinon.spy,
|
||||
stub = sinon.stub;
|
||||
|
||||
// A mock version of http.ServerResponse to be used in tests
|
||||
var MockResponse = module.exports = function MockResponse() {
|
||||
this.end = spy();
|
||||
|
||||
this.headers = {};
|
||||
};
|
||||
|
||||
MockResponse.prototype.setHeader = function setHeader(name, value) {
|
||||
this.headers[name] = value;
|
||||
};
|
Loading…
Reference in New Issue