Skip to content

Commit

Permalink
Update css-select to the latest version 🚀 (#1158)
Browse files Browse the repository at this point in the history
Breaking change: Invalid selectors now throw Errors, not SyntaxErrors.
  • Loading branch information
greenkeeper[bot] authored and fb55 committed Sep 9, 2020
1 parent fe0f903 commit c1a5e5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"node": ">= 0.6"
},
"dependencies": {
"css-select": "~1.2.0",
"css-select": "~2.0.0",
"dom-serializer": "~0.1.0",
"entities": "~1.1.1",
"htmlparser2": "^3.9.1",
Expand Down
14 changes: 10 additions & 4 deletions test/api/traversing.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ describe('$(...)', function() {
expect(q('[alltheway]')).to.have.length(0);
});

it('should throw a SyntaxError if given an invalid selector', function() {
it('should throw an Error if given an invalid selector', function() {
expect(function() {
$('#fruits').find(':bah');
}).to.throwException(/unmatched pseudo-class/);
}).to.throwException(function(err) {
expect(err).to.be.a(Error);
expect(err.message).to.contain('unmatched pseudo-class')
});
});

describe('(cheerio object) :', function() {
Expand Down Expand Up @@ -451,10 +454,13 @@ describe('$(...)', function() {
expect($('.orange').siblings('.peach')).to.have.length(0);
});

it('(selector) : should throw a SyntaxError if given an invalid selector', function() {
it('(selector) : should throw an Error if given an invalid selector', function() {
expect(function() {
$('.orange').siblings(':bah');
}).to.throwException(/unmatched pseudo-class/);
}).to.throwException(function(err) {
expect(err).to.be.a(Error);
expect(err.message).to.contain('unmatched pseudo-class')
});
});

it('(selector) : does not consider the contents of siblings when filtering (GH-374)', function() {
Expand Down

0 comments on commit c1a5e5e

Please sign in to comment.