Repository: jquery/jquery
File: test/unit/selector.js (JavaScript)

Code before:
		},
		"Detached children": {
			input: [
				detached2.childNodes[ 3 ],
				detached2.childNodes[ 0 ],
				detached2.childNodes[ 2 ],
				detached2.childNodes[ 1 ]
			],
			expected: [
				detached2.childNodes[ 0 ],
				detached2.childNodes[ 1 ],
				detached2.childNodes[ 2 ],
				detached2.childNodes[ 3 ]
			]
		},
		"Attached/detached mixture": {
			input: [ detached1, fixture, detached2, document, detachedChild, body, detachedGrandchild ],
			expected: [ document, body, fixture ],
			length: 3
		}
	};

	jQuery.each( tests, function( label, test ) {
		var length = test.length || test.input.length;
		//we duplicate the test.input, because if not it is modified by the uniqueSort and the second test becomes worthless
    assert.deepEqual( jQuery.uniqueSort( test.input.slice( 0 ) ).slice( 0, length ), test.expected, label + " (array)" );
		assert.deepEqual( jQuery.uniqueSort( new Arrayish( test.input ) ).sliceForTestOnly( 0, length ), test.expected, label + " (quasi-array)" );
	} );
} );

testIframe(
	"jQuery.uniqueSort works cross-window (trac-14381)",
	"selector/mixed_sort.html",
	function( assert, jQuery, window, document, actual, expected ) {
		assert.expect( 1 );

		assert.deepEqual( actual, expected, "Mixed array was sorted correctly" );
	}
);

testIframe(
	"jQuery selector cache collides with multiple jQueries on a page",
	"selector/cache.html",
	function( assert, jQuery, window, document ) {
		var $cached = window.$cached;

		assert.expect( 4 );
		assert.notStrictEqual( jQuery, $cached, "Loaded two engines" );
		assert.deepEqual( $cached( ".test a" ).get(), [ document.getElementById( "collision" ) ], "Select collision anchor with first sizzle" );
		assert.equal( jQuery( ".evil a" ).length, 0, "Select nothing with second sizzle" );
		assert.equal( jQuery( ".evil a" ).length, 0, "Select nothing again with second sizzle" );

Review comment (suggestion):
```suggestion
		assert.deepEqual( jQuery.uniqueSort( test.input.slice( 0 ) ).slice( 0, length ), test.expected, label + " (array)" );
```

Code after:
		},
		"Detached children": {
			input: [
				detached2.childNodes[ 3 ],
				detached2.childNodes[ 0 ],
				detached2.childNodes[ 2 ],
				detached2.childNodes[ 1 ]
			],
			expected: [
				detached2.childNodes[ 0 ],
				detached2.childNodes[ 1 ],
				detached2.childNodes[ 2 ],
				detached2.childNodes[ 3 ]
			]
		},
		"Attached/detached mixture": {
			input: [ detached1, fixture, detached2, document, detachedChild, body, detachedGrandchild ],
			expected: [ document, body, fixture ],
			length: 3
		}
	};

	jQuery.each( tests, function( label, test ) {
		var length = test.length || test.input.length;
		// We duplicate `test.input` because otherwise it is modified by `uniqueSort`
		// and the second test becomes worthless.
		assert.deepEqual( jQuery.uniqueSort( test.input.slice( 0 ) ).slice( 0, length ),
			test.expected, label + " (array)" );
		assert.deepEqual( jQuery.uniqueSort( new Arrayish( test.input ) ).sliceForTestOnly( 0, length ),
			test.expected, label + " (quasi-array)" );
	} );
} );

testIframe(
	"jQuery.uniqueSort works cross-window (trac-14381)",
	"selector/mixed_sort.html",
	function( assert, jQuery, window, document, actual, expected ) {
		assert.expect( 1 );

		assert.deepEqual( actual, expected, "Mixed array was sorted correctly" );
	}
);

testIframe(
	"jQuery selector cache collides with multiple jQueries on a page",
	"selector/cache.html",
	function( assert, jQuery, window, document ) {
		var $cached = window.$cached;

		assert.expect( 4 );
		assert.notStrictEqual( jQuery, $cached, "Loaded two engines" );