Detail view: 'View all' action tests

This commit is contained in:
Brian Federle 2012-03-23 15:39:53 -07:00
parent e53aa0c147
commit 5998eb84c7

View File

@ -3,11 +3,15 @@
setup: function() {
cloudStack.dialog.__confirm = cloudStack.dialog.confirm;
cloudStack.ui.notifications.__add = cloudStack.ui.notifications.add;
$.fn.__cloudBrowser = $.fn.cloudBrowser;
$.fn.__listView = $.fn.listView;
},
teardown: function() {
cloudStack.dialog.confirm = cloudStack.dialog.__confirm;
cloudStack.ui.notifications.add = cloudStack.ui.notifications.__add;
$.fn.cloudBrowser = $.fn.__cloudBrowser;
$.fn.listView = $.fn.__listView;
}
});
@ -359,4 +363,118 @@
stop();
$detailView.find('.button.refresh').click();
});
test('View all, 1 section', function() {
var $browser = $('<div>').appendTo('#qunit-fixture');
var detailView = {
$browser: $browser,
context: {},
viewAll: { label: 'testListView', path: 'testListView' },
tabs: {
tabA: {
title: 'tabA',
fields: [{ fieldA: { label: 'fieldA' }}],
dataProvider: function(args) { args.response.success({ data: { fieldA: 'fieldAContent' } }); start(); }
}
}
};
var testListView = {};
var $detailView = $('<div>').appendTo('#qunit-fixture');
$('<div>').attr('cloudStack-container', true).data('cloudStack-args', {
sections: {
testListView: testListView
}
}).appendTo('#qunit-fixture');
stop();
$.fn.cloudBrowser = function(cmd, args) {};
$browser.cloudBrowser();
$detailView.detailView(detailView);
equal($detailView.find('.detail-group.actions td.view-all').size(), 1, 'Detail view has view all button');
stop();
$.fn.listView = function(args, options) {
start();
ok(true, 'List view called');
equal(args, testListView, 'Correct list view passed');
ok(args.$browser.size(), 'Browser passed in args');
ok($.isPlainObject(args.ref), 'Ref passed in args');
equal(args.id, 'testListView', 'Correct section ID');
return this;
};
$.fn.cloudBrowser = function(cmd, args) {
start();
equal(cmd, 'addPanel', 'Browser add panel called');
stop();
args.complete($('<div>'));
};
$detailView.find('.view-all a').click();
});
test('View all, subsections', function() {
var $browser = $('<div>').appendTo('#qunit-fixture');
var detailView = {
$browser: $browser,
context: {},
viewAll: { label: 'testListView', path: 'testSection.listViewB' },
tabs: {
tabA: {
title: 'tabA',
fields: [{ fieldA: { label: 'fieldA' }}],
dataProvider: function(args) { args.response.success({ data: { fieldA: 'fieldAContent' } }); start(); }
}
}
};
var listViewA = {};
var listViewB = {};
var $detailView = $('<div>').appendTo('#qunit-fixture');
$('<div>').attr('cloudStack-container', true).data('cloudStack-args', {
sections: {
testSection: {
sections: {
listViewA: { listView: listViewA },
listViewB: { listView: listViewB }
}
}
}
}).appendTo('#qunit-fixture');
stop();
$.fn.cloudBrowser = function(cmd, args) {};
$browser.cloudBrowser();
$detailView.detailView(detailView);
equal($detailView.find('.detail-group.actions td.view-all').size(), 1, 'Detail view has view all button');
stop();
$.fn.listView = function(args, options) {
start();
ok(true, 'List view called');
equal(args.listView, listViewB, 'Correct list view passed');
ok(args.$browser.size(), 'Browser passed in args');
ok($.isPlainObject(args.ref), 'Ref passed in args');
equal(args.id, 'testSection', 'Correct section ID');
return this;
};
$.fn.cloudBrowser = function(cmd, args) {
start();
equal(cmd, 'addPanel', 'Browser add panel called');
stop();
args.complete($('<div>'));
};
$detailView.find('.view-all a').click();
});
}(jQuery));