purescript-httpurple/test/HTTPure/SpecHelpers.js

41 lines
777 B
JavaScript
Raw Normal View History

"use strict";
2017-09-26 06:08:07 +00:00
exports.mockRequestImpl = function(method) {
2017-07-20 22:48:59 +00:00
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;
2017-07-18 05:25:14 +00:00
2017-07-20 22:48:59 +00:00
return stream;
2017-07-18 05:25:14 +00:00
};
2017-07-20 22:48:59 +00:00
};
2017-07-18 05:25:14 +00:00
};
2017-07-20 22:48:59 +00:00
};
2017-07-18 05:25:14 +00:00
};
exports.mockResponse = function() {
2017-07-20 22:48:59 +00:00
return {
body: "",
headers: {},
2017-07-20 22:48:59 +00:00
write: function(str) {
this.body = this.body + str;
},
2017-07-20 22:48:59 +00:00
end: function() { },
2017-07-20 22:48:59 +00:00
setHeader: function(header, val) {
this.headers[header] = val;
}
};
};