Skip to content

Commit b6fcffc

Browse files
antonbrianc
anton
authored andcommitted
write messages for assertions
1 parent 4ef99b2 commit b6fcffc

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

test/unit/copystream/copyfrom-tests.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var buf1 = new Buffer("asdfasd"),
2424
buf3 = new Buffer(542),
2525
buf4 = new Buffer("93jfemialfjkasjlfas");
2626

27-
test('stream has to finish data stream to connection exactly once', function () {
27+
test('CopyFromStream, start streaming before data, end after data. no drain event', function () {
2828
var stream = new CopyFromStream();
2929
var conn = new ConnectionImitation();
3030
stream.on('drain', function () {
@@ -38,8 +38,9 @@ test('stream has to finish data stream to connection exactly once', function ()
3838
stream.end(conn.updateHasToBeSend(buf4));
3939
assert.ok(!stream.writable, "stream has not to be writable");
4040
stream.end();
41+
assert.equal(conn.hasToBeSend, conn.send);
4142
});
42-
test('', function () {
43+
test('CopyFromStream, start streaming after end, end after data. drain event', function () {
4344
var stream = new CopyFromStream();
4445
assert.emits(stream, 'drain', function() {}, 'drain have to be emitted');
4546
var conn = new ConnectionImitation()
@@ -51,8 +52,9 @@ test('', function () {
5152
assert.ok(!stream.writable, "stream has not to be writable");
5253
stream.end();
5354
stream.startStreamingToConnection(conn);
55+
assert.equal(conn.hasToBeSend, conn.send);
5456
});
55-
test('', function () {
57+
test('CopyFromStream, start streaming between data chunks. end after data. drain event', function () {
5658
var stream = new CopyFromStream();
5759
var conn = new ConnectionImitation()
5860
assert.emits(stream, 'drain', function() {}, 'drain have to be emitted');
@@ -62,10 +64,11 @@ test('', function () {
6264
stream.write(conn.updateHasToBeSend(buf3));
6365
assert.ok(stream.writable, "stream has to be writable");
6466
stream.end(conn.updateHasToBeSend(buf4));
67+
assert.equal(conn.hasToBeSend, conn.send);
6568
assert.ok(!stream.writable, "stream has not to be writable");
6669
stream.end();
6770
});
68-
test('', function () {
71+
test('CopyFromStream, start sreaming before end. end stream with data. drain event', function () {
6972
var stream = new CopyFromStream();
7073
var conn = new ConnectionImitation()
7174
assert.emits(stream, 'drain', function() {}, 'drain have to be emitted');
@@ -75,10 +78,11 @@ test('', function () {
7578
stream.startStreamingToConnection(conn);
7679
assert.ok(stream.writable, "stream has to be writable");
7780
stream.end(conn.updateHasToBeSend(buf4));
81+
assert.equal(conn.hasToBeSend, conn.send);
7882
assert.ok(!stream.writable, "stream has not to be writable");
7983
stream.end();
8084
});
81-
test('', function(){
85+
test('CopyFromStream, start streaming after end. end with data. drain event', function(){
8286
var stream = new CopyFromStream();
8387
var conn = new ConnectionImitation()
8488
assert.emits(stream, 'drain', function() {}, 'drain have to be emitted');
@@ -89,6 +93,7 @@ test('', function(){
8993
assert.ok(stream.writable, "stream has to be writable");
9094
stream.end(conn.updateHasToBeSend(buf4));
9195
stream.startStreamingToConnection(conn);
96+
assert.equal(conn.hasToBeSend, conn.send);
9297
assert.ok(!stream.writable, "stream has not to be writable");
9398
stream.end();
9499
});

test/unit/copystream/copyto-tests.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ DataCounter.prototype = {
1313
this.recievedBytes += chunk.length;
1414
},
1515
assert: function () {
16-
assert.equal(this.sendBytes, this.recievedBytes);
16+
assert.equal(this.sendBytes, this.recievedBytes, "data bytes send and recieved has to match");
1717
}
1818
};
1919
var buf1 = new Buffer("asdfasd"),
@@ -36,7 +36,7 @@ test('CopyToStream pause/resume/close', function () {
3636
var stream = new CopyToStream(),
3737
dc = new DataCounter();
3838
stream.on('data', dc.recieve.bind(dc));
39-
assert.emits(stream, 'end', function () {}, '');
39+
assert.emits(stream, 'end', function () {}, 'stream has to emit end after closing');
4040
stream.pause();
4141
stream.handleChunk(dc.send(buf1));
4242
stream.handleChunk(dc.send(buf2));
@@ -50,7 +50,7 @@ test('CopyToStream pause/resume/close', function () {
5050
dc.assert();
5151
stream.pause();
5252
stream.handleChunk(dc.send(buf4));
53-
assert(dc.sendBytes - dc.recievedBytes, buf4.length);
53+
assert(dc.sendBytes - dc.recievedBytes, buf4.length, "stream has not emit, data while it is in paused state");
5454
stream.resume();
5555
dc.assert();
5656
stream.close();
@@ -59,7 +59,7 @@ test('CopyToStream error', function () {
5959
var stream = new CopyToStream(),
6060
dc = new DataCounter();
6161
stream.on('data', dc.recieve.bind(dc));
62-
assert.emits(stream, 'error', function () {}, '');
62+
assert.emits(stream, 'error', function () {}, 'stream has to emit error event, when error method called');
6363
stream.handleChunk(dc.send(buf1));
6464
stream.handleChunk(dc.send(buf2));
6565
stream.error(new Error('test error'));

0 commit comments

Comments
 (0)