From 44f7fd4f97b7a8f99308d01ae3701792ca1276e5 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Fri, 23 Mar 2012 14:08:44 -0700 Subject: [PATCH] Add detail view action filter tests --- ui/tests/test.detailView.js | 50 ++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/ui/tests/test.detailView.js b/ui/tests/test.detailView.js index bd4c372c9ec..de914b773e9 100644 --- a/ui/tests/test.detailView.js +++ b/ui/tests/test.detailView.js @@ -176,7 +176,7 @@ $detailView.detailView(detailView); }); - test('Action', function() { + test('Action', function() { var detailView = { actions: { actionA: { @@ -242,7 +242,7 @@ args.action(); // Perform action }; - + cloudStack.ui.notifications.add = function(notification, success, successArgs) { stop(); equal(notification.desc, 'testActionANotification', 'Correct notification message for action A'); @@ -258,7 +258,7 @@ args.action(); // Perform action }; - + cloudStack.ui.notifications.add = function(notification, success, successArgs) { start(); equal(notification.desc, 'testActionBNotification', 'Correct notification message for action B'); @@ -269,11 +269,53 @@ $detailView.find('.detail-actions .action.actionB a').click(); // triggers action, not action's container }); + test('Action filter', function() { + var detailView = { + actions: { + actionA: { + label: 'testActionA', + action: function(args) {} + }, + actionB: { + label: 'testActionB', + action: function(args) {} + } + }, + tabs: { + tabA: { + title: 'tabA', + fields: { + fieldA: { label: 'fieldA' }, + fieldB: { label: 'fieldB' } + }, + dataProvider: function(args) { + args.response.success({ + actionFilter: function() { + return ['actionA']; + }, + data: { + fieldA: 'fieldAContent', + fieldB: 'fieldBContent' + } + }); + } + } + } + }; + var $detailView = $('
'); + + $detailView.detailView(detailView).appendTo('#qunit-fixture'); + + equal($detailView.find('.detail-actions .action').size(), 1, 'Correct action count'); + equal($detailView.find('.detail-actions .action.actionA').size(), 1, 'actionA present'); + notEqual($detailView.find('.detail-actions .action.actionB').size(), 1, 'actionB not present'); + }); + test('Refresh', function() { var dataA = ['dataLoad1A', 'dataLoad2A']; var dataB = ['dataLoad1B', 'dataLoad2B']; var index = 0; - + var detailView = { tabs: { tabA: {