buffered-node-process-spec.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* eslint-disable no-new */
  2. const path = require('path');
  3. const BufferedNodeProcess = require('../src/buffered-node-process');
  4. describe('BufferedNodeProcess', function() {
  5. it('executes the script in a new process', function() {
  6. const exit = jasmine.createSpy('exitCallback');
  7. let output = '';
  8. const stdout = lines => (output += lines);
  9. let error = '';
  10. const stderr = lines => (error += lines);
  11. const args = ['hi'];
  12. const command = path.join(__dirname, 'fixtures', 'script.js');
  13. new BufferedNodeProcess({ command, args, stdout, stderr, exit });
  14. waitsFor(() => exit.callCount === 1);
  15. runs(function() {
  16. expect(output).toBe('hi');
  17. expect(error).toBe('');
  18. expect(args).toEqual(['hi']);
  19. });
  20. });
  21. it('suppresses deprecations in the new process', function() {
  22. const exit = jasmine.createSpy('exitCallback');
  23. let output = '';
  24. const stdout = lines => (output += lines);
  25. let error = '';
  26. const stderr = lines => (error += lines);
  27. const command = path.join(
  28. __dirname,
  29. 'fixtures',
  30. 'script-with-deprecations.js'
  31. );
  32. new BufferedNodeProcess({ command, stdout, stderr, exit });
  33. waitsFor(() => exit.callCount === 1);
  34. runs(function() {
  35. expect(output).toBe('hi');
  36. expect(error).toBe('');
  37. });
  38. });
  39. });