From dd3707b630a382f83ec3cf7d4bbf9b19ea8a40e0 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Thu, 8 Mar 2012 14:44:20 -0800 Subject: [PATCH] Add initial list view action tests --- ui/tests/test.listView.js | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/ui/tests/test.listView.js b/ui/tests/test.listView.js index f55a577847c..8c1c674b578 100644 --- a/ui/tests/test.listView.js +++ b/ui/tests/test.listView.js @@ -247,4 +247,59 @@ equal($listView.find('.list-view tbody tr:first td:first span').html(), '1A', 'First table cell has correct data'); equal($listView.find('.list-view tbody tr:last td:last span').html(), '2B', 'Last table cell has correct data'); }); + + test('Actions', function() { + var $listView = $('
'); + var listView = { + listView: { + section: 'test123', + fields: { + fieldA: { label: 'testFieldA' }, + fieldB: { label: 'testFieldB' } + }, + actions: { + basicSync: { + label: 'basicAction', + messages: { + confirm: function() { + return 'basicActionConfirm'; + }, + notification: function() { + return 'basicActionNotification'; + } + }, + action: function(args) { + args.response.success(); + } + } + }, + dataProvider: function(args) { + args.response.success({ + data: [ + { + fieldA: '1A', + fieldB: '1B', + fieldC: '1C' + }, + { + fieldA: '2A', + fieldB: '2B', + fieldC: '2C' + } + ] + }); + } + } + }; + + ok($listView.listView(listView), 'Initialize list view'); + equal($listView.find('table thead th').size(), 3, 'Correct header column count'); + equal($listView.find('table thead th.actions').size(), 1, 'Action header column present'); + equal($listView.find('table tbody tr:first td').size(), 3, 'Correct data column count'); + equal($listView.find('table tbody tr:first td.actions').size(), 1, 'Action data column present'); + equal($listView.find('table tbody tr:first td.actions .action').size(), 1, 'Correct action count'); + equal($listView.find('table tbody tr:first td.actions .action:first .icon').size(), 1, 'Action has icon'); + ok($listView.find('table tbody tr:first td.actions .action:first').hasClass('basicSync'), + 'First action has ID as CSS class'); + }); }(jQuery));