diff options
| author | Gias Kay Lee | 2014-01-03 00:22:10 +0800 |
|---|---|---|
| committer | Igor Minar | 2014-01-02 16:14:16 -0800 |
| commit | c9705b755645a4bfe066243f2ba15a733c3787e1 (patch) | |
| tree | f93771ddd101ab15bc51c8e1ca9a86e9b2bf3043 /test/ng/directive | |
| parent | 53ec33f07fd75d76fc5109c0b24c86aa25219058 (diff) | |
| download | angular.js-c9705b755645a4bfe066243f2ba15a733c3787e1.tar.bz2 | |
fix(ngRepeat): allow for more flexible coding style in ngRepeat expression
With this change it's possible to split the ng-repeat expression into multiple
lines at any point in the expression where white-space is expected.
Closes #5537
Closes #5598
Diffstat (limited to 'test/ng/directive')
| -rw-r--r-- | test/ng/directive/ngRepeatSpec.js | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index 2d70d4a4..638f082c 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -177,22 +177,6 @@ describe('ngRepeat', function() { }); - it('should allow expressions over multiple lines', function() { - scope.isTrue = function() { - return true; - }; - element = $compile( - '<ul>' + - '<li ng-repeat="item in items\n' + - '| filter:isTrue">{{item.name}}</li>' + - '</ul>')(scope); - scope.items = [{name: 'igor'}]; - scope.$digest(); - - expect(element.find('li').text()).toBe('igor'); - }); - - it('should track using provided function when a filter is present', function() { scope.newArray = function (items) { var newArray = []; @@ -354,6 +338,38 @@ describe('ngRepeat', function() { }); + it('should allow expressions over multiple lines', function() { + element = $compile( + '<ul>' + + '<li ng-repeat="item in items\n' + + '| filter:isTrue">{{item.name}}/</li>' + + '</ul>')(scope); + + scope.isTrue = function() {return true;}; + scope.items = [{name: 'igor'}, {name: 'misko'}]; + + scope.$digest(); + + expect(element.text()).toEqual('igor/misko/'); + }); + + + it('should strip white space characters correctly', function() { + element = $compile( + '<ul>' + + '<li ng-repeat="item \t\n \t in \n \t\n\n \nitems \t\t\n | filter:\n\n{' + + '\n\t name:\n\n \'ko\'\n\n}\n\n | orderBy: \t \n \'name\' \n\n' + + 'track \t\n by \n\n\t $index \t\n ">{{item.name}}/</li>' + + '</ul>')(scope); + + scope.items = [{name: 'igor'}, {name: 'misko'}]; + + scope.$digest(); + + expect(element.text()).toEqual('misko/'); + }); + + it('should not ngRepeat over parent properties', function() { var Class = function() {}; Class.prototype.abc = function() {}; |
