aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/selectmenu/selectmenu_options.js
blob: 21e276b5d9519d856453fdff9bc0777034472d39 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(function ($) {

module("selectmenu: options");

test("appendTo another element", function () {
	expect( 8 );
	
	var detached = $( "<div>" ),
		element = $("#speed").selectmenu();
	equal( element.selectmenu( "menuWidget" ).parent().parent()[0], document.body, "defaults to body" );
	element.selectmenu( "destroy" );

	element.selectmenu({
		appendTo: ".sm-wrap"
	});
	equal( element.selectmenu( "menuWidget" ).parent().parent()[0], $( "#sm-wrap1" )[0], "first found element" );
	equal( $( "#sm-wrap2 .ui-selectmenu" ).length, 0, "only appends to one element" );
	element.selectmenu( "destroy" );

	$( "#sm-wrap2" ).addClass( "ui-front" );
	element.selectmenu();
	equal( element.selectmenu( "menuWidget" ).parent().parent()[0], $( "#sm-wrap2" )[0], "null, inside .ui-front" );
	element.selectmenu( "destroy" );
	$( "#sm-wrap2" ).removeClass( "ui-front" );

	element.selectmenu().selectmenu( "option", "appendTo", "#sm-wrap1" );
	equal( element.selectmenu( "menuWidget" ).parent().parent()[0], $( "#sm-wrap1" )[0], "modified after init" );
	element.selectmenu( "destroy" );

	element.selectmenu({
		appendTo: detached
	});
	equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached jQuery object" );
	element.selectmenu( "destroy" );

	element.selectmenu({
		appendTo: detached[0]
	});
	equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached DOM element" );
	element.selectmenu( "destroy" );

	element.selectmenu().selectmenu( "option", "appendTo", detached );
	equal( element.selectmenu( "menuWidget" ).parent().parent()[0], detached[0], "detached DOM element via option()" );
	element.selectmenu( "destroy" );
});


test("dropdown: CSS styles", function () {
	expect(2);

	var element = $("#speed").selectmenu(),
		button = element.selectmenu("widget"),
		menu = element.selectmenu("menuWidget");

	element.selectmenu("open");
	ok( button.hasClass("ui-corner-top") && !button.hasClass("ui-corner-all") && button.find("span.ui-icon").hasClass("ui-icon-triangle-1-s"), "button styles dropdown");
	ok( menu.hasClass("ui-corner-bottom") && !menu.hasClass("ui-corner-all"), "menu styles dropdown");
});

test("pop-up: CSS styles", function () {
	expect(2);

	var element = $("#speed").selectmenu({
			dropdown: false
		}),
		button = element.selectmenu("widget"),
		menu = element.selectmenu("menuWidget");

	element.selectmenu("close");
	ok( !button.hasClass("ui-corner-top") && button.hasClass("ui-corner-all") && button.find("span.ui-icon").hasClass("ui-icon-triangle-2-n-s"), "button styles pop-up");
	ok( !menu.hasClass("ui-corner-bottom") && menu.hasClass("ui-corner-all"), "menu styles pop-up");
});

})(jQuery);