<commit_before>/*
shoestring unit tests - using qUnit
*/
(function(undefined){

module( 'Extensions' );
test( '`.live()` is an alias of `.on()`', function() {
	ok( shoestring( "body" ).live == shoestring( "body" ).on );
});

test( '`.closest()`', function() {
	var $fixture = shoestring( '#qunit-fixture' );
	$fixture.html( '<div class="parent second"><div class="parent first"><div class="child"></div></div></div>' );

	equal( $fixture.find( '.child' ).closest( '.parent' ).length, 1, 'Closest returns only one element.' );

	ok( $fixture.find( '.child' ).closest( '.parent' ).is( '.first' ), 'Closest returns from the bottom up.' );
});

test( '`.insertAfter()`', function() {
	var $fixture = shoestring( '#qunit-fixture' ),
		$sibling;

	$fixture.html( '<div id="sibling"></div>' );
	$sibling = shoestring( '#sibling' );

	shoestring( '<div id="insertAfter">' ).insertAfter( $sibling );

	equal( $fixture.children().length, 2, 'Has two children.' );
	ok( $sibling.next().is( '#insertAfter' ), 'Inserted properly.' );
});

test( '`.insertBefore()`', function() {
	var $fixture = shoestring( '#qunit-fixture' ),
		$sibling;

	$fixture.html( '<div id="sibling"></div>' );
	$sibling = shoestring( '#sibling' );

	shoestring( '<div id="insertBefore">' ).insertBefore( $sibling );

	equal( $fixture.children().length, 2, 'Has two children.' );
	ok( $sibling.prev().is( '#insertBefore' ), 'Inserted properly.' );
});


test( '`.html()`', function() {
	var $fixture = shoestring( '#qunit-fixture' ),
		htmlStr = '<div id="sibling"></div>';

	$fixture.html( htmlStr );
	equal( $fixture[0].innerHTML, htmlStr, '.html(str) set properly.' );
	equal( $fixture.html(), htmlStr, '.html() get properly.' );
});

test( '`.siblings()`', function() {
	var $fixture = shoestring( '#qunit-fixture' );
	$fixture.html( '<div></div><div id="sibling"></div><div></div>' );

	strictEqual( $( '#imaginary_element' ).siblings().length, 0, '.siblings runs on an empty set.' );
	equal( $( '#sibling' ).siblings().length, 2, '.siblings returns non-empty set.' );
});

})();<commit_msg>ensure closest returns the current element on match<commit_after>/*
shoestring unit tests - using qUnit
*/
(function(undefined){

module( 'Extensions' );
test( '`.live()` is an alias of `.on()`', function() {
	ok( shoestring( "body" ).live == shoestring( "body" ).on );
});

test( '`.closest()`', function() {
	var $fixture = shoestring( '#qunit-fixture' );
	$fixture.html( '<div class="parent second"><div class="parent first"><div class="child"></div></div></div>' );

	var $child = $fixture.find( '.child' );

	equal( $child[0], $child.closest( '.child' )[0], 'Closest returns current element on match' );

	equal( $child.closest( '.parent' ).length, 1, 'Closest returns only one element.' );

	ok( $child.closest( '.parent' ).is( '.first' ), 'Closest returns from the bottom up.' );
});

test( '`.insertAfter()`', function() {
	var $fixture = shoestring( '#qunit-fixture' ),
		$sibling;

	$fixture.html( '<div id="sibling"></div>' );
	$sibling = shoestring( '#sibling' );

	shoestring( '<div id="insertAfter">' ).insertAfter( $sibling );

	equal( $fixture.children().length, 2, 'Has two children.' );
	ok( $sibling.next().is( '#insertAfter' ), 'Inserted properly.' );
});

test( '`.insertBefore()`', function() {
	var $fixture = shoestring( '#qunit-fixture' ),
		$sibling;

	$fixture.html( '<div id="sibling"></div>' );
	$sibling = shoestring( '#sibling' );

	shoestring( '<div id="insertBefore">' ).insertBefore( $sibling );

	equal( $fixture.children().length, 2, 'Has two children.' );
	ok( $sibling.prev().is( '#insertBefore' ), 'Inserted properly.' );
});


test( '`.html()`', function() {
	var $fixture = shoestring( '#qunit-fixture' ),
		htmlStr = '<div id="sibling"></div>';

	$fixture.html( htmlStr );
	equal( $fixture[0].innerHTML, htmlStr, '.html(str) set properly.' );
	equal( $fixture.html(), htmlStr, '.html() get properly.' );
});

test( '`.siblings()`', function() {
	var $fixture = shoestring( '#qunit-fixture' );
	$fixture.html( '<div></div><div id="sibling"></div><div></div>' );

	strictEqual( $( '#imaginary_element' ).siblings().length, 0, '.siblings runs on an empty set.' );
	equal( $( '#sibling' ).siblings().length, 2, '.siblings returns non-empty set.' );
});

})();

{'fraction_non_alphanumeric': 0.2413063909774436, 'fraction_numerical': 0.003289473684210526, 'mean_word_length': 4.839506172839506, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, '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': '6239431', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1527, 'n_words': 368}