diff options
| author | Ben Ripkens | 2013-05-20 19:10:04 +0200 | 
|---|---|---|
| committer | Igor Minar | 2013-07-13 22:22:28 -0700 | 
| commit | 724819e3cfd8aeda1f724fb527db2b57494be9b7 (patch) | |
| tree | 50a64772698458b7c7ecc29f48b85d6f164980f7 /test/AngularSpec.js | |
| parent | 32f8a04c8f3eb480b3f405ac6b1324c96025b2fc (diff) | |
| download | angular.js-724819e3cfd8aeda1f724fb527db2b57494be9b7.tar.bz2 | |
fix(angular.equals): add support for regular expressions
Regular expression objects didn't used to be considered to be equal when using
'angular.equals'. Dirty checking therefore failed to recognize a
property modification.
Closes #2685
Diffstat (limited to 'test/AngularSpec.js')
| -rw-r--r-- | test/AngularSpec.js | 28 | 
1 files changed, 28 insertions, 0 deletions
| diff --git a/test/AngularSpec.js b/test/AngularSpec.js index da70aef7..151aac0a 100644 --- a/test/AngularSpec.js +++ b/test/AngularSpec.js @@ -278,6 +278,17 @@ describe('angular', function() {        expect(equals({}, {hasOwnProperty: 1})).toBe(false);        expect(equals({}, {toString: null})).toBe(false);      }); + +    it('should compare regular expressions', function() { +      expect(equals(/abc/, /abc/)).toBe(true); +      expect(equals(/abc/i, new RegExp('abc', 'i'))).toBe(true); +      expect(equals(new RegExp('abc', 'i'), new RegExp('abc', 'i'))).toBe(true); +      expect(equals(new RegExp('abc', 'i'), new RegExp('abc'))).toBe(false); +      expect(equals(/abc/i, /abc/)).toBe(false); +      expect(equals(/abc/, /def/)).toBe(false); +      expect(equals(/^abc/, /abc/)).toBe(false); +      expect(equals(/^abc/, '/^abc/')).toBe(false); +    });    });    describe('size', function() { @@ -654,6 +665,23 @@ describe('angular', function() {      });    }); + +  describe('isRegExp', function() { +    it('should return true for RegExp object', function() { +      expect(isRegExp(/^foobar$/)).toBe(true); +      expect(isRegExp(new RegExp('^foobar$/'))).toBe(true); +    }); + +    it('should return false for non RegExp objects', function() { +      expect(isRegExp([])).toBe(false); +      expect(isRegExp('')).toBe(false); +      expect(isRegExp(23)).toBe(false); +      expect(isRegExp({})).toBe(false); +      expect(isRegExp(new Date())).toBe(false); +    }); +  }); + +    describe('compile', function() {      it('should link to existing node and create scope', inject(function($rootScope, $compile) {        var template = angular.element('<div>{{greeting = "hello world"}}</div>'); | 
