purescript-httpurple/test/HTTPure/SpecHelpers.js
2017-09-25 23:08:07 -07:00

41 lines
777 B
JavaScript

"use strict";
exports.mockRequestImpl = function(method) {
return function(url) {
return function(body) {
return function(headers) {
return function() {
var stream = new require('stream').Readable({
read: function(size) {
this.push(body);
this.push(null);
}
});
stream.method = method;
stream.url = url;
stream.headers = headers;
return stream;
};
};
};
};
};
exports.mockResponse = function() {
return {
body: "",
headers: {},
write: function(str) {
this.body = this.body + str;
},
end: function() { },
setHeader: function(header, val) {
this.headers[header] = val;
}
};
};