aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/menu/menu_methods.js
blob: 6ad7bc13411a4e0cf70156477ec8e88c57f4d01f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * menu_methods.js
 */
(function($) {

var log = TestHelpers.menu.log,
	click = TestHelpers.menu.click;

module("menu: methods");

test( "enable/disable", function() {
	expect( 3 );
	var menu = $( "#menu1" ).menu({
		select: function(event, ui) {
			log();
		}
	});
	menu.menu("disable");
	ok(menu.is(".ui-state-disabled"),"Missing ui-state-disabled class");
	log("click",true);
	click(menu,"1");
	log("afterclick");
	menu.menu("enable");
	ok(menu.not(".ui-state-disabled"),"Has ui-state-disabled class");
	log("click");
	click(menu,"1");
	log("afterclick");
	equal( $("#log").html(), "afterclick,1,click,afterclick,click,", "Click order not valid.");
});

test( "refresh", function() {
	expect( 3 );
	var menu = $( "#menu1" ).menu();
	equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items");
	menu.append("<li><a href='#'>test item</a></li>").menu("refresh");
	equal(menu.find(".ui-menu-item").length,6,"Incorrect number of menu items");
	menu.find(".ui-menu-item:last").remove().end().menu("refresh");
	equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items");
});

test("destroy", function() {
	domEqual("#menu1", function() {
		$("#menu1").menu().menu("destroy");
	});
});


})(jQuery);