diff options
| author | Igor Minar | 2013-05-24 11:00:14 -0700 | 
|---|---|---|
| committer | Vojta Jina | 2013-05-24 17:03:21 -0700 | 
| commit | b8ea7f6aba2e675b85826b0bee1f21ddd7b866a5 (patch) | |
| tree | f3b34e25e27d088bec9b698b246d49f86281de36 /test/ng/directive | |
| parent | 88eaea8e7bf025a7805a5d20f5d47472e4f26f6f (diff) | |
| download | angular.js-b8ea7f6aba2e675b85826b0bee1f21ddd7b866a5.tar.bz2 | |
feat(ngError): add error message compression and better error messages
- add toThrowNg matcher
Diffstat (limited to 'test/ng/directive')
| -rw-r--r-- | test/ng/directive/inputSpec.js | 14 | ||||
| -rw-r--r-- | test/ng/directive/ngRepeatSpec.js | 14 | ||||
| -rw-r--r-- | test/ng/directive/selectSpec.js | 4 | 
3 files changed, 16 insertions, 16 deletions
| diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index f8898074..68caf1f5 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -43,7 +43,7 @@ describe('NgModelController', function() {      }      expect(exception.message). -        toMatch(/Non-assignable model expression: 1\+2 \(<input( value="")? ng-model="1\+2">\)/); +        toMatch(/^\[NgErr6\] ngModel error! Expression '1\+2' is non\-assignable\. Element: <input( value="")? ng-model="1\+2">$/);    })); @@ -457,7 +457,7 @@ describe('input', function() {      expect(function() {        compileInput('<input type="text" ng-model="throw \'\'">');        scope.$digest(); -    }).toThrow("Syntax Error: Token '''' is an unexpected token at column 7 of the expression [throw ''] starting at ['']."); +    }).toThrow("[NgErr24] Syntax Error: Token '''' is an unexpected token at column 7 of the expression [throw ''] starting at [''].");    }); @@ -548,11 +548,11 @@ describe('input', function() {      }); -    xit('should throw an error when scope pattern can\'t be found', function() { -      compileInput('<input type="text" ng-model="foo" ng-pattern="fooRegexp" />'); - -      expect(function() { changeInputValueTo('xx'); }). -          toThrow('Expected fooRegexp to be a RegExp but was undefined'); +    it('should throw an error when scope pattern can\'t be found', function() { +      expect(function() { +        compileInput('<input type="text" ng-model="foo" ng-pattern="fooRegexp" />'); +        scope.$apply(); +      }).toThrowNg('ngPattern error! Expected fooRegexp to be a RegExp but was undefined.');      });    }); diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index e7e9af35..ac6ceb83 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -269,7 +269,7 @@ describe('ngRepeat', function() {      element = jqLite('<ul><li ng-repeat="i dont parse"></li></ul>');      $compile(element)(scope);      expect($exceptionHandler.errors.shift()[0].message). -        toBe("Expected ngRepeat in form of '_item_ in _collection_[ track by _id_]' but got 'i dont parse'."); +        toBe("[NgErr7] ngRepeat error! Expected expression in form of '_item_ in _collection_[ track by _id_]' but got 'i dont parse'.");    }); @@ -277,7 +277,7 @@ describe('ngRepeat', function() {        element = jqLite('<ul><li ng-repeat="i dont parse in foo"></li></ul>');        $compile(element)(scope);      expect($exceptionHandler.errors.shift()[0].message). -        toBe("'item' in 'item in collection' should be identifier or (key, value) but got 'i dont parse'."); +        toBe("[NgErr8] ngRepeat error! '_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got 'i dont parse'.");    }); @@ -481,7 +481,7 @@ describe('ngRepeat', function() {        scope.items = [a, a, a];        scope.$digest();        expect($exceptionHandler.errors.shift().message). -          toEqual('Duplicates in a repeater are not allowed. Repeater: item in items key: object:003'); +          toEqual("[NgErr50] ngRepeat error! Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: item in items, Duplicate key: object:003");        // recover        scope.items = [a]; @@ -501,7 +501,7 @@ describe('ngRepeat', function() {        scope.items = [d, d, d];        scope.$digest();        expect($exceptionHandler.errors.shift().message). -          toEqual('Duplicates in a repeater are not allowed. Repeater: item in items key: object:009'); +          toEqual("[NgErr50] ngRepeat error! Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: item in items, Duplicate key: object:009");        // recover        scope.items = [a]; @@ -563,7 +563,7 @@ describe('ngRepeat ngAnimate', function() {    }    function applyCSS(element, cssProp, cssValue) { -    element.css(cssProp, cssValue);     +    element.css(cssProp, cssValue);      element.css(vendorPrefix + cssProp, cssValue);    } @@ -592,7 +592,7 @@ describe('ngRepeat ngAnimate', function() {        '<div><div ' +          'ng-repeat="item in items" ' +          'ng-animate="{enter: \'custom-enter\'}">' + -        '{{ item }}' +  +        '{{ item }}' +        '</div></div>'      ))($rootScope); @@ -635,7 +635,7 @@ describe('ngRepeat ngAnimate', function() {        '<div><div ' +          'ng-repeat="item in items" ' +          'ng-animate="{leave: \'custom-leave\'}">' + -        '{{ item }}' +  +        '{{ item }}' +        '</div></div>'      ))($rootScope); diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 0cb2a812..5a168f53 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -494,8 +494,8 @@ describe('select', function() {      it('should throw when not formated "? for ? in ?"', function() {        expect(function() {          compile('<select ng-model="selected" ng-options="i dont parse"></select>'); -      }).toThrow("Expected ngOptions in form of '_select_ (as _label_)? for (_key_,)?_value_ in" + -                 " _collection_ (track by _expr_)?' but got 'i dont parse'."); +      }).toThrowNg("ngOptions error! Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in" + +                   " _collection_' but got 'i dont parse'.");      }); | 
