Added some tests

This commit is contained in:
2021-06-23 22:30:45 +02:00
parent 24f897e907
commit 3d3d7fae48
3796 changed files with 218744 additions and 3 deletions

37
tests/node_modules/resumer/test/resume.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
var test = require('tape');
var resumer = require('../');
var concat = require('concat-stream');
test('implicit resume', function (t) {
t.plan(1);
var s = createStream();
s.pipe(concat(function (err, body) {
t.equal(body, 'beep boop\n');
}));
});
test('pause/resume', function (t) {
t.plan(2);
var s = createStream();
s.pause();
var paused = true;
setTimeout(function () {
paused = false;
s.resume();
}, 100);
s.pipe(concat(function (err, body) {
t.equal(paused, false);
t.equal(body, 'beep boop\n');
}));
});
function createStream () {
var stream = resumer();
stream.queue('beep boop\n');
stream.queue(null);
return stream;
}

36
tests/node_modules/resumer/test/through.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
var test = require('tape');
var resumer = require('../');
var concat = require('concat-stream');
test('through write/end', function (t) {
t.plan(2);
var s = createStream();
s.on('okok', function () {
t.ok(true);
});
s.pipe(concat(function (err, body) {
t.equal(body, 'BEGIN\nRAWR\nEND\n');
}));
setTimeout(function () {
s.end('rawr\n');
}, 50);
});
function createStream () {
var stream = resumer(write, end);
stream.queue('BEGIN\n');
return stream;
function write (x) {
this.queue(String(x).toUpperCase());
}
function end () {
this.emit('okok');
this.queue('END\n');
this.queue(null);
}
}