void-exit.test.js 934 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var assert = require('assert');
  2. var M = require('../lib/Machine.constructor');
  3. // TODO: deprecate `void`-- `outputExample: undefined` works just as well.
  4. // (technically you can't smash output passed through that way, but that's
  5. // probably fine, considering it has never come up so far after ~3 yrs of
  6. // production use!)
  7. describe('void exit', function() {
  8. it('should not return data from a voided exit', function(done) {
  9. var machine = {
  10. inputs: {
  11. foo: {
  12. example: 'foo bar'
  13. }
  14. },
  15. exits: {
  16. success: {
  17. void: true
  18. },
  19. error: {
  20. example: 'world'
  21. }
  22. },
  23. fn: function (inputs, exits, deps) {
  24. exits(null, 'foo');
  25. }
  26. };
  27. M.build(machine)
  28. .configure({
  29. foo: 'hello'
  30. })
  31. .exec(function(err, result) {
  32. if(err) { return done(err); }
  33. assert(!result);
  34. done();
  35. });
  36. });
  37. });