Repository: ambari Updated Branches: refs/heads/trunk f165b5cd5 -> 31a497f45
AMBARI-9959 JS error after opening popup with hosts to add to config group. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6c949f4b Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6c949f4b Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6c949f4b Branch: refs/heads/trunk Commit: 6c949f4b52be096c1b98e01abb3ac448ca50055f Parents: f165b5c Author: aBabiichuk <ababiic...@cybervisiontech.com> Authored: Fri Mar 6 12:15:16 2015 +0200 Committer: aBabiichuk <ababiic...@cybervisiontech.com> Committed: Fri Mar 6 14:02:14 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/views/common/table_view.js | 2 +- ambari-web/test/views/common/table_view_test.js | 97 ++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/6c949f4b/ambari-web/app/views/common/table_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/table_view.js b/ambari-web/app/views/common/table_view.js index 72c4bf7..5c51daf 100644 --- a/ambari-web/app/views/common/table_view.js +++ b/ambari-web/app/views/common/table_view.js @@ -455,7 +455,7 @@ App.TableView = Em.View.extend(App.UserPref, { }); this.set('filteredContent', result); } else { - this.set('filteredContent', content.toArray()); + this.set('filteredContent', content ? content.toArray() : []); } }.observes('content.length'), http://git-wip-us.apache.org/repos/asf/ambari/blob/6c949f4b/ambari-web/test/views/common/table_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/table_view_test.js b/ambari-web/test/views/common/table_view_test.js index c311834..76800a6 100644 --- a/ambari-web/test/views/common/table_view_test.js +++ b/ambari-web/test/views/common/table_view_test.js @@ -286,4 +286,101 @@ describe('App.TableView', function () { }); }); + describe('#filter', function () { + + var cases = [ + { + filterConditions: [ + { + iColumn: 1, + type: 'string', + value: 'v0' + } + ], + content: [ + Em.Object.create({ + c0: 'v0' + }), + Em.Object.create({ + c1: 'v1' + }) + ], + filteredContent: [], + title: 'no matches' + }, + { + filterConditions: [ + { + iColumn: 0, + type: 'string', + value: 'v1' + } + ], + content: [ + Em.Object.create({ + c0: 'v1' + }), + Em.Object.create({ + c0: 'v11' + }), + Em.Object.create({ + c1: 'v01' + }) + ], + filteredContent: [ + Em.Object.create({ + c0: 'v1' + }), + Em.Object.create({ + c0: 'v11' + }) + ], + title: 'matches present' + }, + { + filterConditions: [], + content: [ + Em.Object.create({ + c0: 'v0' + }), + Em.Object.create({ + c1: 'v1' + }) + ], + filteredContent: [ + Em.Object.create({ + c0: 'v0' + }), + Em.Object.create({ + c1: 'v1' + }) + ], + title: 'no filter conditions' + }, + { + filterConditions: [], + filteredContent: [], + title: 'no filter conditions, no content' + } + ]; + + beforeEach(function () { + view = App.TableView.create({ + colPropAssoc: ['c0', 'c1'] + }); + }); + + cases.forEach(function (item) { + it(item.title, function () { + view.setProperties({ + filterConditions: item.filterConditions, + content: item.content + }); + view.filter(); + expect(view.get('filteredContent')).to.eql(item.filteredContent); + }); + }); + + }); + });