From e1a3a6f2d99168e52ebdd40f1f082dac8248508a Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 6 Mar 2012 14:58:19 -0800 Subject: [PATCH] Add list view tests --- ui/tests/index.html | 1 + ui/tests/test.listView.js | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 ui/tests/test.listView.js diff --git a/ui/tests/index.html b/ui/tests/index.html index 8a3ec5962f6..74a5555e6a1 100644 --- a/ui/tests/index.html +++ b/ui/tests/index.html @@ -78,5 +78,6 @@ + diff --git a/ui/tests/test.listView.js b/ui/tests/test.listView.js new file mode 100644 index 00000000000..77feedc26d3 --- /dev/null +++ b/ui/tests/test.listView.js @@ -0,0 +1,40 @@ +(function($) { + module('List view', { + setup: function() { + $.fx.off = true; + } + }); + + test('Basic', function() { + var listView = { + listView: { + section: 'test123', + fields: { + fieldA: { label: 'testFieldA' }, + fieldB: { label: 'testFieldB' } + }, + dataProvider: function(args) { + args.response.success({ + data: [] + }); + } + } + }; + var $listView; + + ok($listView = $('
').listView(listView), 'Initialize list view'); + equal($listView.find('.list-view').size(), 1, 'List view has container div'); + equal($listView.find('.list-view.test123').size(), 1, 'Container div has section ID as CSS class'); + equal($listView.find('.list-view table').size(), 2, 'List view has split tables'); + equal($listView.find('.list-view .fixed-header table thead tr').size(), 1, 'List view has fixed table header'); + equal($listView.find('.list-view .fixed-header table thead th').size(), 2, 'List view has correct column headers'); + equal($listView.find('.list-view .fixed-header table thead th:first').html(), 'testFieldA', 'First header has correct label'); + ok($listView.find('.list-view .fixed-header table thead th:first').hasClass('fieldA'), 'First header has correct class'); + ok($listView.find('.list-view .fixed-header table thead th:last').hasClass('fieldB'), 'First header has correct class'); + equal($listView.find('.list-view .fixed-header table thead th:last').html(), 'testFieldB', 'First header has correct label'); + equal($listView.find('.list-view table tbody tr').size(), 1, 'List view has table body'); + equal($listView.find('.toolbar').size(), 1, 'List view has toolbar'); + equal($listView.find('.toolbar .text-search .search-bar input[type=text]').size(), 1, 'Toolbar has search box'); + equal($listView.find('.toolbar .text-search .button.search').size(), 1, 'Toolbar has search button'); + }); +}(jQuery));