Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Aug 18, 2020
1 parent cf6c132 commit 247a421
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 32 deletions.
13 changes: 10 additions & 3 deletions test/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ describe('commands', function () {
.send('GROUP test.groups.foo')
.expect(/^211 /)
.send('HEAD')
.expect('221 1 <4c51f95eda05@lists.example.org>');
.expect('221 1 <4c51f95eda05@lists.example.org>')
.expect(/^From: /)
.expect(/^Xref: /)
.expect('.');
});

it('HEAD should fail in empty group', function () {
Expand All @@ -176,15 +179,19 @@ describe('commands', function () {
it('HEAD should retrieve an article header by id', function () {
return client
.send('HEAD <d417dea0c7a3@lists.example.org>')
.expect('221 0 <d417dea0c7a3@lists.example.org>');
.expect('221 0 <d417dea0c7a3@lists.example.org>')
.expect(/^From: /)
.expect('.');
});

it('HEAD should retrieve an article header by number', function () {
return client
.send('GROUP test.groups.foo')
.expect(/^211/)
.send('HEAD 2')
.expect('221 2 <d417dea0c7a3@lists.example.org>');
.expect('221 2 <d417dea0c7a3@lists.example.org>')
.expect(/^From: /)
.expect('.');
});

it('HEAD should fail if no article found by number', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/flatten-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('flatten-stream', function () {
});


it.skip('should start reading from next stream when previous is finished', function () {
it('should start reading from next stream when previous is finished', function () {
let stream = flatten();

// stream that writes 'foo', 'bar' and never ends
Expand Down
28 changes: 15 additions & 13 deletions test/helpers/asline.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,26 @@ AsLine.prototype.skip = function (lines = 1) {
// Reads entire source buffer until data is available, then closes stream
//
AsLine.prototype.end = function (expect) {
this._promise = this._promise.then(() => {
let buffer = [];
let data;
this._promise = this._promise
.then(() => new Promise(resolve => setTimeout(resolve, 10)))
.then(() => {
let buffer = [];
let data;

while ((data = this._input.read()) !== null) {
buffer.push(data);
}
while ((data = this._input.read()) !== null) {
buffer.push(data);
}

this._input.end();
this._input.end();

let actual = buffer.join(this._linebreak);
let actual = buffer.join(this._linebreak);

if (typeof expect === 'string') {
assert.equal(actual, expect);
}
if (typeof expect === 'string') {
assert.equal(actual, expect);
}

return actual;
});
return actual;
});

return this;
};
Expand Down
32 changes: 17 additions & 15 deletions test/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('pipeline', function () {
});


it.skip('should handle errors from streams', function () {
it('should handle errors from streams', function () {
let error;

nntp._onError = function (err) {
Expand All @@ -181,20 +181,22 @@ describe('pipeline', function () {

return new stream.Readable({
read() {
count++;

if (count === 1) {
this.push({
name: 'test.groups.foo',
min_index: 1,
max_index: 2,
total: 2
});
} else {
let err = new Error('Test stream error');
err.code = 'ETEST';
this.emit('error', err);
}
setTimeout(() => {
count++;

if (count === 1) {
this.push({
name: 'test.groups.foo',
min_index: 1,
max_index: 2,
total: 2
});
} else {
let err = new Error('Test stream error');
err.code = 'ETEST';
this.emit('error', err);
}
}, 10);
},
objectMode: true
});
Expand Down

0 comments on commit 247a421

Please sign in to comment.