streams.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. var test = require('tape'),
  3. Vinyl = require('vinyl'),
  4. gulpUglify = require('../'),
  5. Readable = require('stream').Readable,
  6. Stream = require('stream'),
  7. PluginError = require('gulp-util/lib/PluginError');
  8. var testContentsInput = 'function errorFunction(error) {';
  9. var testFile1 = new Vinyl({
  10. cwd: "/home/terin/broken-promises/",
  11. base: "/home/terin/broken-promises/test",
  12. path: "/home/terin/broken-promises/test/test1.js",
  13. contents: stringStream()
  14. });
  15. test('should emit error for stream files', function(t) {
  16. t.plan(6);
  17. var stream = gulpUglify();
  18. stream
  19. .on('data', function() {
  20. t.fail('should emit error for streams');
  21. })
  22. .on('error', function(e) {
  23. t.pass('emitted error');
  24. t.ok(e instanceof PluginError, 'error is a PluginError');
  25. t.equal(e.plugin, 'gulp-uglify', 'error is from gulp-uglify');
  26. t.equal(e.fileName, testFile1.path, 'error reports the correct file');
  27. // t.ok(e.stack, 'error has a stack');
  28. t.skip('error should have a stack');
  29. t.false(e.showStack, 'error is configured to not print stack');
  30. });
  31. stream.write(testFile1);
  32. stream.end();
  33. });
  34. function stringStream() {
  35. var stream = new Readable();
  36. stream._read = function() {
  37. this.push('terin');
  38. this.push(null);
  39. };
  40. return stream;
  41. }