Skip to content

Commit

Permalink
Add more StreamHandlerSpec unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hershal committed Jun 30, 2017
1 parent 7fef6fa commit 1757e3d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/StreamHandlerSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class BasicStreamHandlerDelegate implements IStreamHandlerDelegate {

constructor() {
this.buffer = [];

/* Default */
this.streamSerializationString = '\n';
}

/* Delegate methods */
Expand Down Expand Up @@ -41,7 +44,6 @@ describe('Stream Handler', function () {
});

it('Serializes a simple hello world', function (done) {
handlerDelegate.streamSerializationString = '\n';
handler.once(stdin).then(() => {
expect(handlerDelegate.buffer).to.deep.equal(['hello world']);
done();
Expand All @@ -59,5 +61,25 @@ describe('Stream Handler', function () {
stdin.write('hello world');
stdin.end();
});

it('Serializes a block of input', function (done) {
handler.once(stdin).then(() => {
expect(handlerDelegate.buffer).to.deep.equal(['hello world',
'mellow world']);
done();
});
stdin.write('hello world\nmellow world');
stdin.end();
});

it('Serializes a block of input with a space chunk string', function (done) {
handlerDelegate.streamSerializationString = ' ';
handler.once(stdin).then(() => {
expect(handlerDelegate.buffer).to.deep.equal(['hello', 'world\nmellow', 'world']);
done();
});
stdin.write('hello world\nmellow world');
stdin.end();
});
});
});

0 comments on commit 1757e3d

Please sign in to comment.