From b8ea7f6aba2e675b85826b0bee1f21ddd7b866a5 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 24 May 2013 11:00:14 -0700 Subject: feat(ngError): add error message compression and better error messages - add toThrowNg matcher --- test/ng/directive/inputSpec.js | 14 +++++++------- test/ng/directive/ngRepeatSpec.js | 14 +++++++------- test/ng/directive/selectSpec.js | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'test/ng/directive') 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 \(\)/); + toMatch(/^\[NgErr6\] ngModel error! Expression '1\+2' is non\-assignable\. Element: $/); })); @@ -457,7 +457,7 @@ describe('input', function() { expect(function() { compileInput(''); 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(''); - - 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(''); + 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(''); $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(''); $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() { '
' + - '{{ item }}' + + '{{ item }}' + '
' ))($rootScope); @@ -635,7 +635,7 @@ describe('ngRepeat ngAnimate', function() { '
' + - '{{ item }}' + + '{{ item }}' + '
' ))($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(''); - }).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'."); }); -- cgit v1.2.3