You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2014/01/30 23:41:18 UTC

[27/50] [abbrv] git commit: updated refs/heads/ui-restyle to 849d601

Add listView async tests


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/08d124d6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/08d124d6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/08d124d6

Branch: refs/heads/ui-restyle
Commit: 08d124d6b664bedea28b75fab02c6fd217a67a47
Parents: 0518936
Author: Brian Federle <br...@citrix.com>
Authored: Tue Jan 28 11:24:20 2014 -0800
Committer: Brian Federle <br...@citrix.com>
Committed: Tue Jan 28 11:24:20 2014 -0800

----------------------------------------------------------------------
 ui/tests/test.widget.listView.js | 88 +++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/08d124d6/ui/tests/test.widget.listView.js
----------------------------------------------------------------------
diff --git a/ui/tests/test.widget.listView.js b/ui/tests/test.widget.listView.js
index 2209c42..3640a5a 100644
--- a/ui/tests/test.widget.listView.js
+++ b/ui/tests/test.widget.listView.js
@@ -86,4 +86,92 @@
             equal($field.html(), v.label, k + '-> Has correct label');
         });
     });
+
+    test('Data loading state', function() {
+        var $listView = listView();
+
+        equal($listView.find('table.body tr.loading').size(), 1, 'Row has loading state');
+        equal($listView.find('table.body tr.loading td.loading.icon').size(), 1, 'Row cell has loading icon');
+    });
+
+    asyncTest('Data provider: basic', function() {
+        expect(3);
+        var $listView = listView({
+            listView: {
+                fields: {
+                    fieldA: { label: 'TestFieldA' },
+                    fieldB: { label: 'TestFieldB' }
+                },
+                dataProvider: function(args) {
+                    args.response.success({ data: [] });
+                    
+                    ok(true, 'Data provider called');
+                    start();
+                }
+            }
+        });
+
+        equal($listView.find('.data-table table.body tbody tr.empty td').size(), 1, 'Body table has empty table row');
+        equal($listView.find('.data-table table.body tbody tr.empty td').html(), 'label.no.data', 'Empty contents notice displayed');
+    });
+
+    asyncTest('Data provider: load data', function() {
+        var $listView = listView({
+            listView: {
+                fields: {
+                    fieldA: { label: 'TestFieldA' },
+                    fieldB: { label: 'TestFieldB' }
+                },
+                dataProvider: function(args) {
+                    args.response.success({
+                        data: [
+                            { fieldA: 'FieldDataA', fieldB: 'FieldDataB' }
+                        ]
+                    });
+                    
+                    start();
+                }
+            }
+        });
+
+        equal($listView.find('table.body tbody tr').size(), 1, 'Body table has table row');
+        equal($listView.find('table.body tbody tr td').size(), 2, 'Body table has table cells');
+        equal($listView.find('table.body tbody tr td.fieldA > span').html(), 'FieldDataA', 'FieldDataA content present');
+        equal($listView.find('table.body tbody tr td.fieldB > span').html(), 'FieldDataB', 'FieldDataB content present');
+    });
+
+    asyncTest('Data provider: multiple rows of data', function() {
+        var testData = [
+            { fieldA: 'FieldDataA1', fieldB: 'FieldDataB1' },
+            { fieldA: 'FieldDataA2', fieldB: 'FieldDataB2' },
+            { fieldA: 'FieldDataA3', fieldB: 'FieldDataB3' }
+        ];
+        
+        var $listView = listView({
+            listView: {
+                fields: {
+                    fieldA: { label: 'TestFieldA' },
+                    fieldB: { label: 'TestFieldB' }
+                },
+                dataProvider: function(args) {
+                    args.response.success({
+                        data: testData
+                    });
+                    
+                    start();
+                }
+            }
+        });
+
+        equal($listView.find('table.body tbody tr').size(), 3, 'Body table has correct # of table rows');
+
+        $(testData).map(function(index, data) {
+            var $tr = $listView.find('table.body tbody tr').filter(function() {
+                return $(this).index() === index;
+            });
+            
+            equal($tr.find('td.fieldA > span').html(), 'FieldDataA' + (index + 1), 'FieldDataA' + (index + 1) + ' present');
+            equal($tr.find('td.fieldB > span').html(), 'FieldDataB' + (index + 1), 'FieldDataB' + (index + 1) + ' present');
+        });
+    });
 }());