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