diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/AngularSpec.js | 27 | 
1 files changed, 27 insertions, 0 deletions
diff --git a/test/AngularSpec.js b/test/AngularSpec.js index 6d462b14..b4e90175 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -54,3 +54,30 @@ describe("copy", function(){    });  }); + +describe('equals', function(){ +  it('should return true if same object', function(){ +    var o = {}; +    expect(equals(o, o)).toEqual(true); +    expect(equals(1, '1')).toEqual(true); +    expect(equals(1, '2')).toEqual(false); +  }); + +  it('should recurse into object', function(){ +    expect(equals({}, {})).toEqual(true); +    expect(equals({name:'misko'}, {name:'misko'})).toEqual(true); +    expect(equals({name:'misko', age:1}, {name:'misko'})).toEqual(false); +    expect(equals({name:'misko'}, {name:'misko', age:1})).toEqual(false); +    expect(equals({name:'misko'}, {name:'adam'})).toEqual(false); +    expect(equals(['misko'], ['misko'])).toEqual(true); +    expect(equals(['misko'], ['adam'])).toEqual(false); +    expect(equals(['misko'], ['misko', 'adam'])).toEqual(false); +  }); + +  it('should ignore $ member variables', function(){ +    expect(equals({name:'misko', $id:1}, {name:'misko', $id:2})).toEqual(true); +    expect(equals({name:'misko'}, {name:'misko', $id:2})).toEqual(true); +    expect(equals({name:'misko', $id:1}, {name:'misko'})).toEqual(true); +  }); + +});  | 
