|
247 | 247 | equal($listView.find('.list-view tbody tr:first td:first span').html(), '1A', 'First table cell has correct data'); |
248 | 248 | equal($listView.find('.list-view tbody tr:last td:last span').html(), '2B', 'Last table cell has correct data'); |
249 | 249 | }); |
| 250 | + |
| 251 | + test('Actions', function() { |
| 252 | + var $listView = $('<div>'); |
| 253 | + var listView = { |
| 254 | + listView: { |
| 255 | + section: 'test123', |
| 256 | + fields: { |
| 257 | + fieldA: { label: 'testFieldA' }, |
| 258 | + fieldB: { label: 'testFieldB' } |
| 259 | + }, |
| 260 | + actions: { |
| 261 | + basicSync: { |
| 262 | + label: 'basicAction', |
| 263 | + messages: { |
| 264 | + confirm: function() { |
| 265 | + return 'basicActionConfirm'; |
| 266 | + }, |
| 267 | + notification: function() { |
| 268 | + return 'basicActionNotification'; |
| 269 | + } |
| 270 | + }, |
| 271 | + action: function(args) { |
| 272 | + args.response.success(); |
| 273 | + } |
| 274 | + } |
| 275 | + }, |
| 276 | + dataProvider: function(args) { |
| 277 | + args.response.success({ |
| 278 | + data: [ |
| 279 | + { |
| 280 | + fieldA: '1A', |
| 281 | + fieldB: '1B', |
| 282 | + fieldC: '1C' |
| 283 | + }, |
| 284 | + { |
| 285 | + fieldA: '2A', |
| 286 | + fieldB: '2B', |
| 287 | + fieldC: '2C' |
| 288 | + } |
| 289 | + ] |
| 290 | + }); |
| 291 | + } |
| 292 | + } |
| 293 | + }; |
| 294 | + |
| 295 | + ok($listView.listView(listView), 'Initialize list view'); |
| 296 | + equal($listView.find('table thead th').size(), 3, 'Correct header column count'); |
| 297 | + equal($listView.find('table thead th.actions').size(), 1, 'Action header column present'); |
| 298 | + equal($listView.find('table tbody tr:first td').size(), 3, 'Correct data column count'); |
| 299 | + equal($listView.find('table tbody tr:first td.actions').size(), 1, 'Action data column present'); |
| 300 | + equal($listView.find('table tbody tr:first td.actions .action').size(), 1, 'Correct action count'); |
| 301 | + equal($listView.find('table tbody tr:first td.actions .action:first .icon').size(), 1, 'Action has icon'); |
| 302 | + ok($listView.find('table tbody tr:first td.actions .action:first').hasClass('basicSync'), |
| 303 | + 'First action has ID as CSS class'); |
| 304 | + }); |
250 | 305 | }(jQuery)); |
0 commit comments