no-compress.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. var test = require('tape'),
  3. Vinyl = require('vinyl'),
  4. gulpUglify = require('../'),
  5. uglifyjs = require('uglify-js');
  6. var testContentsInput = '"use strict"; (function(console, first, second) {\n\tconsole.log(first + second)\n}(5, 10))';
  7. var testContentsExpected = uglifyjs.minify(testContentsInput, {fromString: true, compress: false}).code;
  8. var testFile1 = new Vinyl({
  9. cwd: "/home/terin/broken-promises/",
  10. base: "/home/terin/broken-promises/test",
  11. path: "/home/terin/broken-promises/test/test1.js",
  12. contents: new Buffer(testContentsInput)
  13. });
  14. test('should not compress files when `compress: false`', function(t) {
  15. t.plan(7);
  16. var stream = gulpUglify({
  17. compress: false
  18. });
  19. stream.on('data', function(newFile) {
  20. t.ok(newFile, 'emits a file');
  21. t.ok(newFile.path, 'file has a path');
  22. t.ok(newFile.relative, 'file has relative path information');
  23. t.ok(newFile.contents, 'file has contents');
  24. t.ok(newFile instanceof Vinyl, 'file is Vinyl');
  25. t.ok(newFile.contents instanceof Buffer, 'file contents are a buffer');
  26. t.equals(String(newFile.contents), testContentsExpected);
  27. });
  28. stream.write(testFile1);
  29. stream.end();
  30. });