Skip to content

Commit e1a3a6f

Browse files
committed
Add list view tests
1 parent c0c8043 commit e1a3a6f

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

‎ui/tests/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ <h2 id="qunit-userAgent"></h2>
7878
<script src="test.core.js" type="text/javascript"></script>
7979
<script src="test.cloudBrowser.js" type="text/javascript"></script>
8080
<script src="test.notifications.js" type="text/javascript"></script>
81+
<script src="test.listView.js" type="text/javascript"></script>
8182
</body>
8283
</html>

‎ui/tests/test.listView.js‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
(function($) {
2+
module('List view', {
3+
setup: function() {
4+
$.fx.off = true;
5+
}
6+
});
7+
8+
test('Basic', function() {
9+
var listView = {
10+
listView: {
11+
section: 'test123',
12+
fields: {
13+
fieldA: { label: 'testFieldA' },
14+
fieldB: { label: 'testFieldB' }
15+
},
16+
dataProvider: function(args) {
17+
args.response.success({
18+
data: []
19+
});
20+
}
21+
}
22+
};
23+
var $listView;
24+
25+
ok($listView = $('<div>').listView(listView), 'Initialize list view');
26+
equal($listView.find('.list-view').size(), 1, 'List view has container div');
27+
equal($listView.find('.list-view.test123').size(), 1, 'Container div has section ID as CSS class');
28+
equal($listView.find('.list-view table').size(), 2, 'List view has split tables');
29+
equal($listView.find('.list-view .fixed-header table thead tr').size(), 1, 'List view has fixed table header');
30+
equal($listView.find('.list-view .fixed-header table thead th').size(), 2, 'List view has correct column headers');
31+
equal($listView.find('.list-view .fixed-header table thead th:first').html(), 'testFieldA', 'First header has correct label');
32+
ok($listView.find('.list-view .fixed-header table thead th:first').hasClass('fieldA'), 'First header has correct class');
33+
ok($listView.find('.list-view .fixed-header table thead th:last').hasClass('fieldB'), 'First header has correct class');
34+
equal($listView.find('.list-view .fixed-header table thead th:last').html(), 'testFieldB', 'First header has correct label');
35+
equal($listView.find('.list-view table tbody tr').size(), 1, 'List view has table body');
36+
equal($listView.find('.toolbar').size(), 1, 'List view has toolbar');
37+
equal($listView.find('.toolbar .text-search .search-bar input[type=text]').size(), 1, 'Toolbar has search box');
38+
equal($listView.find('.toolbar .text-search .button.search').size(), 1, 'Toolbar has search button');
39+
});
40+
}(jQuery));

0 commit comments

Comments
 (0)