<commit_before>(function ( $ ) {

module( "selectmenu: events", {
	setup: function () {
		this.element = $( "#speed" );
	}
});

test( "change", function () {
	expect( 4 );
	
	var that = this;

	this.element.selectmenu({
		change: function ( event, ui ) {
			ok( event, "change event fired on change" );
			equal( event.type, "selectmenuchange", "event type set to selectmenuchange" );
			equal( ui.item.element[ 0 ], options.eq( ui.item.index )[ 0 ], "ui.item.element contains original option element" );
			equal( ui.item.value, options.eq( ui.item.index ).text(), "ui.item.value property updated correctly" );
		}
	});

	var button = this.element.selectmenu( "widget" ),
		menu = this.element.selectmenu( "menuWidget" ).parent(),
		options = this.element.find( "option" );

	button.simulate( "focus" ).simulate( "click" );
	menu.find( "a" ).first().simulate( "mouseover" ).simulate( "click" );
});


test( "close", function () {
	expect( 2 );

	this.element.selectmenu({
		close: function ( event, ui ) {
			ok( event, "close event fired on close" );
			equal( event.type, "selectmenuclose", "event type set to selectmenuclose" );
		}
	});

	this.element.selectmenu( "open" ).selectmenu( "close" );
});


test( "focus", function () {
	expect( 3 );

	var button, menu, links,
		options = this.element.find( "option" );

	this.element.selectmenu({
		focus: function ( event, ui ) {
			ok( event, "focus event fired on mouseover" );
			equal( event.type, "selectmenufocus", "event type set to selectmenufocus" );
			equal( ui.item.element[ 0 ], options.eq( ui.item.index )[ 0 ], "ui.item.element contains original option element" );
		}
	});

	button = this.element.selectmenu( "widget" ),
	menu = this.element.selectmenu( "menuWidget" );

	button.simulate( "focus" );
	links = menu.find( "li.ui-menu-item a" );

	button.simulate( "click" );

	menu.find( "a" ).last().simulate( "mouseover" );

	this.element.selectmenu( "close" );
});


test( "open", function () {
	expect( 2 );

	this.element.selectmenu({
		open: function ( event, ui ) {
			ok( event, "open event fired on open" );
			equal( event.type, "selectmenuopen", "event type set to selectmenuopen" );
		}
	});
<commit_msg>Selectmenu tests: improve focus callback event test, add keydown focus test, add multiple focus events test<commit_after>(function ( $ ) {

module( "selectmenu: events", {
	setup: function () {
		this.element = $( "#speed" );
	}
});

test( "change", function () {
	expect( 4 );
	
	var that = this;

	this.element.selectmenu({
		change: function ( event, ui ) {
			ok( event, "change event fired on change" );
			equal( event.type, "selectmenuchange", "event type set to selectmenuchange" );
			equal( ui.item.element[ 0 ], options.eq( ui.item.index )[ 0 ], "ui.item.element contains original option element" );
			equal( ui.item.value, options.eq( ui.item.index ).text(), "ui.item.value property updated correctly" );
		}
	});

	var button = this.element.selectmenu( "widget" ),
		menu = this.element.selectmenu( "menuWidget" ).parent(),
		options = this.element.find( "option" );

	button.simulate( "focus" ).simulate( "click" );
	menu.find( "a" ).first().simulate( "mouseover" ).simulate( "click" );
});


test( "close", function () {
	expect( 2 );

	this.element.selectmenu({
		close: function ( event, ui ) {
			ok( event, "close event fired on close" );
			equal( event.type, "selectmenuclose", "event type set to selectmenuclose" );
		}
	});

	this.element.selectmenu( "open" ).selectmenu( "close" );
});


test( "focus", function () {
	expect( 12 );

	var button, menu, links,
		optionIndex = this.element[ 0 ].selectedIndex + 1,
		options = this.element.find( "option" );

	this.element.selectmenu({
		focus: function ( event, ui ) {
			ok( event, "focus event fired on element #" + optionIndex + " mouseover" );
			equal( event.type, "selectmenufocus", "event type set to selectmenufocus" );
			equal( ui.item.index, optionIndex, "ui.item.index contains correct option index" );
			equal( ui.item.element[ 0 ], options.eq( optionIndex )[ 0 ], "ui.item.element contains original option element" );
		}
	});

	button = this.element.selectmenu( "widget" ),
	menu = this.element.selectmenu( "menuWidget" );

	button
		.simulate( "focus" )
		.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
	
	button.simulate( "click" );
	links = menu.find( "li.ui-menu-item a" );
	optionIndex = 0;
	links.eq( optionIndex ).simulate( "mouseover" );	
	optionIndex += 1;
	links.eq( optionIndex ).simulate( "mouseover" );

	// this tests for unwanted, additional focus event on close
	this.element.selectmenu( "close" );
});


test( "open", function () {
	expect( 2 );

	this.element.selectmenu({
		open: function ( event, ui ) {
			ok( event, "open event fired on open" );
			equal( event.type, "selectmenuopen", "event type set to selectmenuopen" );
		}
	});

{'fraction_non_alphanumeric': 0.17394002068252326, 'fraction_numerical': 0.0043433298862461224, 'mean_word_length': 3.836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4643229', 'n_tokens_mistral': 1726, 'n_tokens_neox': 1593, 'n_words': 440}