streams1.js 440 B

123456789101112131415161718192021
  1. var test = require('tape');
  2. var readonly = require('../');
  3. var through = require('through');
  4. var concat = require('concat-stream');
  5. test('streams1', function (t) {
  6. t.plan(2);
  7. var stream = through();
  8. var ro = readonly(stream);
  9. ro.pipe(concat(function (body) {
  10. t.equal(body.toString('utf8'), 'woo');
  11. }));
  12. t.throws(function () {
  13. ro.write('beep');
  14. });
  15. stream.end('woo');
  16. });