error.js 995 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* jshint node: true */
  2. /* global it */
  3. var jedit = require('../');
  4. var gutil = require('gulp-util');
  5. var fs = require('fs');
  6. var should = require('should');
  7. require('mocha');
  8. it('should raise error when missing option', function(done) {
  9. should(function(){jedit();}).throw('missing "editor" option');
  10. done();
  11. });
  12. it('should raise error when invalid type of option', function(done) {
  13. should(function(){jedit(1);}).throw('"editor" option must be a function or object');
  14. done();
  15. });
  16. it('should do path-through when input is null', function(done) {
  17. jedit({})
  18. .on('data', function(file) {
  19. should(file.contents).eql(null);
  20. done();
  21. })
  22. .write(new gutil.File({}));
  23. });
  24. it('should raise error when streaming input', function(done) {
  25. jedit({})
  26. .on('error', function(err) {
  27. err.message.should.equal('Streaming is not supported');
  28. done();
  29. })
  30. .write(new gutil.File({
  31. contents: fs.createReadStream('test/test.json')
  32. }));
  33. });