Skip to content

Commit

Permalink
Merge pull request #120 from benetis/feature/move-from-event-stream
Browse files Browse the repository at this point in the history
tests(document-mapper) move away from event-stream
  • Loading branch information
orangejulius authored Jul 12, 2019
2 parents 1d9c00d + 3d68854 commit 0724d5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"through2": "^3.0.0"
},
"devDependencies": {
"event-stream": "^4.0.0",
"stream-mock": "^2.0.3",
"precommit-hook": "^3.0.0",
"proxyquire": "^2.0.0",
"tap-spec": "^5.0.0",
Expand Down
15 changes: 8 additions & 7 deletions test/DocumentMapperStream.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
var event_stream = require('event-stream');

var createDocumentMapperStream = require('../DocumentMapperStream');
var Document = require('../Document');

function test_stream(input, testedStream, callback) {
var input_stream = event_stream.readArray(input);
var destination_stream = event_stream.writeArray(callback);
const stream_mock = require('stream-mock');

input_stream.pipe(testedStream).pipe(destination_stream);
function test_stream(input, testedStream, callback) {
const reader = new stream_mock.ObjectReadableMock(input);
const writer = new stream_mock.ObjectWritableMock();
writer.on('error', (e) => callback(e));
writer.on('finish', () => callback(null, writer.data));
reader.pipe(testedStream).pipe(writer);
}

module.exports.tests = {};
Expand All @@ -20,7 +21,7 @@ module.exports.tests.DocumentMapperStream = function(test) {
test_stream([document], stream, function(err, results) {
t.equal(results.length, 1, 'stream returns exactly one result');
t.deepEqual(results[0], document.toESDocument(),
'stream transforms Document into object ready to be inserted into Elasticsearch');
'stream transforms Document into object ready to be inserted into Elasticsearch');
t.end();
});
});
Expand Down

0 comments on commit 0724d5d

Please sign in to comment.