You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 lines
590 B

  1. var assert = require('assert')
  2. var chain = require('./index')
  3. console.log('testing...')
  4. var count = 0;
  5. chain(
  6. function(step){ count += step },
  7. function(step){ count += step },
  8. function(step){ count += step }
  9. )(1)
  10. assert.equal(count, 3, 'should chain calls')
  11. count = 0;
  12. chain(
  13. function(step){ count += step },
  14. null, undefined,
  15. function(step){ count += step }
  16. )(1)
  17. assert.equal(count, 2, 'should filter out null and undefined arguments')
  18. var fn = function(){}
  19. assert.equal(chain(fn, null), fn, 'should return the only function argument')
  20. console.log('done. tests pass!')