Skip to content

Commit b6f53de

Browse files
authored
Tests: Make :has selector tests not vulnerable to unrelated failures
Use `assert.selectInFixture` consistently in `:has` tests. Previously, any test failure that happened before this test run made it fail due to an additional paragraph with id `qunit-testresult` injected by QUnit. Closes jquerygh-5497
1 parent a5bac65 commit b6f53de

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

test/unit/selector.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -986,10 +986,10 @@ QUnit.test( "pseudo - nth-last-of-type", function( assert ) {
986986
QUnit[ QUnit.jQuerySelectors ? "test" : "skip" ]( "pseudo - has", function( assert ) {
987987
assert.expect( 4 );
988988

989-
assert.t( "Basic test", "p:has(a)", [ "firstp", "ap", "en", "sap" ] );
990-
assert.t( "Basic test (irrelevant whitespace)", "p:has( a )", [ "firstp", "ap", "en", "sap" ] );
991-
assert.t( "Nested with overlapping candidates",
992-
"#qunit-fixture div:has(div:has(div:not([id])))",
989+
assert.selectInFixture( "Basic test", "p:has(a)", [ "firstp", "ap", "en", "sap" ] );
990+
assert.selectInFixture( "Basic test (irrelevant whitespace)", "p:has( a )", [ "firstp", "ap", "en", "sap" ] );
991+
assert.selectInFixture( "Nested with overlapping candidates",
992+
"div:has(div:has(div:not([id])))",
993993
[ "moretests", "t2037", "fx-test-group", "fx-queue" ] );
994994

995995
// Support: Safari 15.4+, Chrome 105+
@@ -998,8 +998,8 @@ QUnit[ QUnit.jQuerySelectors ? "test" : "skip" ]( "pseudo - has", function( asse
998998
// return no results. Make sure this is accounted for. (gh-5098)
999999
// Note: Chrome 105 has this behavior only in 105.0.5195.125 or newer;
10001000
// initially it shipped with a fully forgiving parsing in `:has()`.
1001-
assert.t( "Nested with list arguments",
1002-
"#qunit-fixture div:has(faketag, div:has(faketag, div:not([id])))",
1001+
assert.selectInFixture( "Nested with list arguments",
1002+
"div:has(faketag, div:has(faketag, div:not([id])))",
10031003
[ "moretests", "t2037", "fx-test-group", "fx-queue" ] );
10041004
} );
10051005

0 commit comments

Comments
 (0)