Skip to content

Commit c242d03

Browse files
chore(deps): bump cheerio from 1.0.0-rc.12 to 1.1.2 (#5732)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: William Durand <[email protected]>
1 parent 8919ce4 commit c242d03

File tree

4 files changed

+130
-52
lines changed

4 files changed

+130
-52
lines changed

package-lock.json

Lines changed: 113 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"addons-scanner-utils": "9.13.0",
5151
"ajv": "8.17.1",
5252
"chalk": "4.1.2",
53-
"cheerio": "1.0.0-rc.12",
53+
"cheerio": "1.1.2",
5454
"columnify": "1.6.0",
5555
"common-tags": "1.8.2",
5656
"deepmerge": "4.3.1",

src/scanners/html.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
import cheerio from 'cheerio';
1+
import * as cheerio from 'cheerio';
22

33
import BaseScanner from 'scanners/base';
44
import * as rules from 'rules/html';
55

66
export default class HTMLScanner extends BaseScanner {
77
_defaultRules = rules;
88

9+
constructor(contents, filename, options = {}) {
10+
super(contents, filename, options);
11+
this.loadHTML = this.options.loadHTML ?? cheerio.load;
12+
}
13+
914
static get scannerName() {
1015
return 'html';
1116
}
1217

1318
async _getContents() {
14-
const htmlDoc = cheerio.load(this.contents);
15-
return htmlDoc;
19+
return this.loadHTML(this.contents);
1620
}
1721
}

tests/unit/scanners/test.html.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import cheerio from 'cheerio';
1+
import * as cheerio from 'cheerio';
22
import { oneLine } from 'common-tags';
33

44
import { VALIDATION_WARNING } from 'const';
@@ -113,13 +113,16 @@ describe('HTML', () => {
113113

114114
it('should return an already-parsed htmlDoc if exists', async () => {
115115
const contents = validHTML();
116-
const htmlScanner = new HTMLScanner(contents, 'index.html');
116+
const loadHTML = sinon.spy(cheerio.load);
117+
const htmlScanner = new HTMLScanner(contents, 'index.html', {
118+
loadHTML,
119+
});
117120

118-
sinon.spy(cheerio, 'load');
121+
const c1 = await htmlScanner.getContents();
122+
const c2 = await htmlScanner.getContents();
119123

120-
await htmlScanner.getContents();
121-
await htmlScanner.getContents();
122-
sinon.assert.calledOnce(cheerio.load);
124+
sinon.assert.calledOnce(loadHTML);
125+
expect(c1).toEqual(c2);
123126
});
124127

125128
it('should export and run all rules in rules/html', async () => {

0 commit comments

Comments
 (0)