Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

object.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Module dependencies.
  3. */
  4. var object = require('..');
  5. describe('.keys(obj)', function(){
  6. it('should return the keys of an object', function(){
  7. var obj = { name: 'tobi', age: 1 };
  8. object.keys(obj).should.eql(['name', 'age']);
  9. })
  10. })
  11. describe('.values(obj)', function(){
  12. it('should return the values of an object', function(){
  13. var obj = { name: 'tobi', age: 1 };
  14. object.values(obj).should.eql(['tobi', 1]);
  15. })
  16. })
  17. describe('.length(obj)', function(){
  18. it('should return key count', function(){
  19. var obj = { name: 'tobi', age: 1 };
  20. object.length(obj).should.equal(2);
  21. })
  22. })
  23. describe('.merge(a, b)', function(){
  24. it('should merge two objects', function(){
  25. var a = { foo: 'bar' };
  26. var b = { bar: 'baz' };
  27. object.merge(a, b).should.eql({ foo: 'bar', bar: 'baz' });
  28. })
  29. it('should give precedence to b', function(){
  30. var a = { foo: 'bar' };
  31. var b = { foo: 'baz' };
  32. object.merge(a, b).should.eql({ foo: 'baz' });
  33. })
  34. })
  35. describe('.isEmpty()', function(){
  36. it('should check if the object is empty', function(){
  37. object.isEmpty({}).should.be.true;
  38. object.isEmpty({ foo: 'bar' }).should.be.false;
  39. })
  40. })