diff options
Diffstat (limited to 'install/static/test/entity_tests.js')
-rw-r--r-- | install/static/test/entity_tests.js | 115 |
1 files changed, 112 insertions, 3 deletions
diff --git a/install/static/test/entity_tests.js b/install/static/test/entity_tests.js index 78fa2d4f3..09967c2c5 100644 --- a/install/static/test/entity_tests.js +++ b/install/static/test/entity_tests.js @@ -69,11 +69,11 @@ test("Testing ipa_entity_generate_views().", function() { ipa_init( "data", true, - function(data, status, xhr) { + function(data, text_status, xhr) { ok(true, "ipa_init() succeeded."); }, - function(xhr, options, thrownError) { - ok(false, "ipa_init() failed: "+thrownError); + function(xhr, text_status, error_thrown) { + ok(false, "ipa_init() failed: "+error_thrown); } ); @@ -135,3 +135,112 @@ test("Testing ipa_entity_generate_views().", function() { "Checking callback invocations" ); }); + +test("Testing ipa_entity_quick_links().", function() { + + var orig_push_state = nav_push_state; + var orig_get_state = nav_get_state; + var orig_remove_state = nav_remove_state; + + var state = {}; + + nav_push_state = function(params) { + $.extend(state, params); + }; + nav_get_state = function(key) { + return state[key]; + }; + nav_remove_state = function(key) { + delete state[key]; + }; + + ipa_ajax_options["async"] = false; + + ipa_init( + "data", + true, + function(data, text_status, xhr) { + ok(true, "ipa_init() succeeded."); + }, + function(xhr, text_status, error_thrown) { + ok(false, "ipa_init() failed: "+error_thrown); + } + ); + + var obj_name = "user"; + var pkey = ipa_objs[obj_name].primary_key; + var pkey_value = "test"; + + var entry_attrs = {}; + entry_attrs[pkey] = [pkey_value]; + + var container = $("<div/>", { + title: obj_name, + class: "search-container" + }); + + var search_table = $('<table/>', { + class: 'search-table' + }).appendTo(container); + + var tbody = $("<tbody/>").appendTo(search_table); + var tr = $("<tr/>").appendTo(tbody); + + ipa_entity_quick_links(tr, null, null, entry_attrs); + + var td = tr.children().first(); + var link = td.children().first(); + + equals( + link.attr("href"), "#details", + "Checking details link" + ); + + link.click(); + + equals( + state[obj_name+"-facet"], "details", + "Checking state[\""+obj_name+"-facet\"]" + ); + + equals( + state[obj_name+"-pkey"], pkey_value, + "Checking state[\""+obj_name+"-pkey\"]" + ); + + var attribute_members = ipa_objs[obj_name].attribute_members; + for (attr_name in attribute_members) { + var objs = attribute_members[attr_name]; + for (var i = 0; i < objs.length; ++i) { + var m = objs[i]; + + link = link.next(); + + equals( + link.attr("href"), "#"+m, + "Checking "+m+" link" + ); + + link.click(); + + equals( + state[obj_name+"-facet"], "associate", + "Checking state[\""+obj_name+"-facet\"]" + ); + + equals( + state[obj_name+"-enroll"], m, + "Checking state[\""+obj_name+"-enroll\"]" + ); + + equals( + state[obj_name+"-pkey"], pkey_value, + "Checking state[\""+obj_name+"-pkey\"]" + ); + } + } + + nav_push_state = orig_push_state; + nav_get_state = orig_get_state; + nav_remove_state = orig_remove_state; +}); |