aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket/src/main/webapp/vnfmarket/node_modules/stream-counter/test/test.js
blob: 0da95660ae18c11366ddf6b6a8cbe328c5e117a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var ByteCounter = require('../');
var fs = require('fs');
var path = require('path');
var assert = require('assert');

var counter = new ByteCounter();
var remainingTests = 2;
counter.once('progress', function() {
  assert.strictEqual(counter.bytes, 5);
  remainingTests -= 1;
});
var is = fs.createReadStream(path.join(__dirname, 'test.txt'));
is.pipe(counter);
is.on('end', function() {
  remainingTests -= 1;
  assert.strictEqual(counter.bytes, 5);
});
process.on('exit', function() {
  assert.strictEqual(remainingTests, 0);
});