diff options
| author | Misko Hevery | 2010-07-19 12:29:24 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-07-19 12:29:24 -0700 |
| commit | 7e96af0fdd9af8c479992363f68578305df0337e (patch) | |
| tree | fccb29641d030f390db1250a98be5412af993e94 /test/AngularSpec.js | |
| parent | cc097867f49673005d47a7f8f0cbe25f7d5c2163 (diff) | |
| download | angular.js-7e96af0fdd9af8c479992363f68578305df0337e.tar.bz2 | |
added equals method to angular.equals and $equals
Diffstat (limited to 'test/AngularSpec.js')
| -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); + }); + +}); |
