ro.js 461 B

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