Skip to content

Commit

Permalink
Add an unit test checking the query of child
Browse files Browse the repository at this point in the history
This test case is intended to highlight two unwanted behaviors:
- The first one is related to issue #742. While using css-select v1.0.0, the child selector '>' would also include indirect descendants and this test case would return '3'.
- The second issue (discussed here: #780 (comment) ) comes while using css-select v1.2.0. In such a case, the context of the '>' selector is the first 'bar' and not 'foo' as intended, which causes a resulting length of '2'.
  • Loading branch information
Delgan committed Jan 2, 2016
1 parent b27bed6 commit 8dc1cc9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/api/traversing.js
Expand Up @@ -47,6 +47,11 @@ describe('$(...)', function() {
expect($('#fruits').find('LI')).to.have.length(3);
});

it('should query immediate descendant only', function() {
var $ = cheerio.load('<foo><bar><bar></bar><bar></bar></bar></foo>');
expect($('foo').find('> bar')).to.have.length(1);
});

it('should query case-sensitively when in xmlMode', function() {
var q = cheerio.load('<caseSenSitive allTheWay>', {xmlMode: true});
expect(q('caseSenSitive')).to.have.length(1);
Expand Down

0 comments on commit 8dc1cc9

Please sign in to comment.