error.js 924 B

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