Skip to content

Commit

Permalink
cheerio-select 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
5saviahv committed Feb 25, 2021
1 parent f851f75 commit d11f965
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions test/api/traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,25 +342,24 @@ describe('$(...)', function () {
expect($('.orange, .pear', food).prev()).toHaveLength(2);
});

// TODO: after cheerio-select update
// i t('() : should maintain elements order', function () {
// var sel = cheerio.load(eleven)('.sel');
// expect(sel).toHaveLength(3);
// expect(sel.eq(0).text()).toBe('Three');
// expect(sel.eq(1).text()).toBe('Nine');
// expect(sel.eq(2).text()).toBe('Eleven');

// // swap last elements
// var el = sel[2];
// sel[2] = sel[1];
// sel[1] = el;

// var result = sel.prev();
// expect(result).toHaveLength(3);
// expect(result.eq(0).text()).toBe('Two');
// expect(result.eq(1).text()).toBe('Ten');
// expect(result.eq(2).text()).toBe('Eight');
// });
it('() : should maintain elements order', function () {
var sel = cheerio.load(eleven)('.sel');
expect(sel).toHaveLength(3);
expect(sel.eq(0).text()).toBe('Three');
expect(sel.eq(1).text()).toBe('Nine');
expect(sel.eq(2).text()).toBe('Eleven');

// swap last elements
var el = sel[2];
sel[2] = sel[1];
sel[1] = el;

var result = sel.prev();
expect(result).toHaveLength(3);
expect(result.eq(0).text()).toBe('Two');
expect(result.eq(1).text()).toBe('Ten');
expect(result.eq(2).text()).toBe('Eight');
});

it('(selector) : should reject elements that violate the filter', function () {
expect($('.orange').prev('.non-existent')).toHaveLength(0);
Expand Down Expand Up @@ -568,11 +567,10 @@ describe('$(...)', function () {
var result = $('.orange').parents('#fruits');
expect(result).toHaveLength(1);
expect(result[0].attribs.id).toBe('fruits');
// TODO: after cheerio-select update
// result = $('.orange').parents('ul');
// expect(result).toHaveLength(2);
// expect(result[0].attribs.id).toBe('fruits');
// expect(result[1].attribs.id).toBe('food');
result = $('.orange').parents('ul');
expect(result).toHaveLength(2);
expect(result[0].attribs.id).toBe('fruits');
expect(result[1].attribs.id).toBe('food');
});

it('() : should not break if the selector does not have any results', function () {
Expand Down

0 comments on commit d11f965

Please sign in to comment.