has.js 442 B

1234567891011121314151617
  1. 'use strict';
  2. var test = require('tape');
  3. var traverse = require('../');
  4. test('has', function (t) {
  5. var obj = { a: 2, b: [4, 5, { c: 6 }] };
  6. t.equal(traverse(obj).has(['b', 2, 'c']), true);
  7. t.equal(traverse(obj).has(['b', 2, 'c', 0]), false);
  8. t.equal(traverse(obj).has(['b', 2, 'd']), false);
  9. t.equal(traverse(obj).has([]), true);
  10. t.equal(traverse(obj).has(['a']), true);
  11. t.equal(traverse(obj).has(['a', 2]), false);
  12. t.end();
  13. });