Skip to content

Commit

Permalink
Added some additional tests for dots inside id/cass selectors
Browse files Browse the repository at this point in the history
Code by @vovayatsyuk, thanks.
  • Loading branch information
fabiospampinato committed Nov 18, 2022
1 parent 9ce28b2 commit 4cb84de
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/modules/traversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ var fixture = '\
<div class="uncle"></div>\
<div class="aunt"></div>\
</div>\
<div class="dotsgrandparent">\
<div class="dotsparent">\
<div class="dots.first"></div>\
<div id="id.with.dots" class="class.with.dots"></div>\
</div>\
</div>\
<iframe src="about:blank"></iframe>\
';

Expand All @@ -36,6 +42,22 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function ()

});

it ( 'supports filtering by a class with dots', function ( t ) {

var children = $('.dotsparent').children ( '.class\\.with\\.dots' );

t.is ( children.length, 1 );

});

it ( 'supports filtering by a id with dots', function ( t ) {

var children = $('.dotsparent').children ( '#id\\.with\\.dots' );

t.is ( children.length, 1 );

});

});

describe ( '$.fn.closest', function ( it ) {
Expand Down Expand Up @@ -112,9 +134,11 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function ()
var grandparent = $('.grandparent');
var all = grandparent.find ( '*' );
var siblings = grandparent.find ( '.sibling' );
var dots = $('.dotsparent').find ( '.class\\.with\\.dots' );

t.is ( all.length, 8 );
t.is ( siblings.length, 5 );
t.is ( dots.length, 1 );

});

Expand Down Expand Up @@ -154,6 +178,15 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function ()

});

it ( 'supports dots in selectors', function ( t ) {

var eles = $('.dotsgrandparent').children ();

t.is ( eles.has ( '.class\\.with\\.dots' ).length, 1 );
t.is ( eles.has ( '#id\\.with\\.dots' ).length, 1 );

});

it ( 'supports nodes', function ( t ) {

var eles = $('.grandparent').children ();
Expand Down Expand Up @@ -182,6 +215,15 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function ()

});

it ( 'check if the collection matches a selector with dots', function ( t ) {

var child = $('.class\\.with\\.dots');

t.true ( child.is ( '.class\\.with\\.dots' ) );
t.true ( child.is ( '#id\\.with\\.dots' ) );

});

});

describe ( '$.fn.next', function ( it ) {
Expand Down Expand Up @@ -214,6 +256,15 @@ describe ( 'Traversal', { beforeEach: getFixtureInit ( fixture ) }, function ()

});

it ( 'supports selector with dots', function ( t ) {

var child = $('.dots\\.first');
var next = $('.class\\.with\\.dots');

t.deepEqual ( child.next ( '.class\\.with\\.dots' ).get (), next.get () );

});

});

describe ( '$.fn.nextAll', function ( it ) {
Expand Down

0 comments on commit 4cb84de

Please sign in to comment.