safe-traverse.js 606 B

123456789101112131415
  1. "use strict";
  2. module.exports = function (t, a) {
  3. var obj = { foo: { bar: { lorem: 12 } } };
  4. a(t(obj), obj, "No props");
  5. a(t(obj, "foo"), obj.foo, "One");
  6. a(t(obj, "raz"), undefined, "One: Fail");
  7. a(t(obj, "foo", "bar"), obj.foo.bar, "Two");
  8. a(t(obj, "dsd", "raz"), undefined, "Two: Fail #1");
  9. a(t(obj, "foo", "raz"), undefined, "Two: Fail #2");
  10. a(t(obj, "foo", "bar", "lorem"), obj.foo.bar.lorem, "Three");
  11. a(t(obj, "dsd", "raz", "fef"), undefined, "Three: Fail #1");
  12. a(t(obj, "foo", "raz", "asdf"), undefined, "Three: Fail #2");
  13. a(t(obj, "foo", "bar", "asd"), undefined, "Three: Fail #3");
  14. };