Files
elasticsearch-js/test/mocks/incomming_message.js
Spencer 7c1573fb07 Use standard and prettier (#10)
* switch from custom eslint config to standard + prettier

* fix new standard eslint violations

* add editorconfig file

* auto-fix all other violations

* update lint yarn script

* remove jshint comment
2019-07-09 13:24:13 -07:00

36 lines
709 B
JavaScript

/**
* Simple Mock of the http.IncommingMessage. Just implmenents the methods the methods
* we use
*
* @type {Constuctor}
*/
module.exports = MockIncommingMessage;
var sinon = require('sinon');
var util = require('util');
var Readable = require('stream').Readable;
if (!Readable) {
Readable = require('events').EventEmitter;
}
function MockIncommingMessage() {
Readable.call(this);
this.setEncoding = sinon.stub();
this.headers = {};
this._read = function() {};
}
util.inherits(MockIncommingMessage, Readable);
/**
* To make the message "talk" do something like this:
*
* process.nextTick(function () {
* if (resp) {
* incom.push(chunk);
* }
* incom.push(null);
* });
*/