def.js 735 B

12345678910111213141516171819202122
  1. var defined = require('../');
  2. var test = require('tape');
  3. test('defined-or', function (t) {
  4. var u = undefined;
  5. t.equal(defined(), u, 'empty arguments');
  6. t.equal(defined(u), u, '1 undefined');
  7. t.equal(defined(u, u), u, '2 undefined');
  8. t.equal(defined(u, u, u, u), u, '4 undefineds');
  9. t.equal(defined(undefined, false, true), false, 'false[0]');
  10. t.equal(defined(false, true), false, 'false[1]');
  11. t.equal(defined(undefined, 0, true), 0, 'zero[0]');
  12. t.equal(defined(0, true), 0, 'zero[1]');
  13. t.equal(defined(3, undefined, 4), 3, 'first arg');
  14. t.equal(defined(undefined, 3, 4), 3, 'second arg');
  15. t.equal(defined(undefined, undefined, 3), 3, 'third arg');
  16. t.end();
  17. });