mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
chore(test-matchers): remove toContainHtml matcher
It used Prettier to normalize the HTML, but Prettier is now async; that doesn't really work for a Jasmine matcher.
This commit is contained in:
parent
bed5a6ee13
commit
0c8200c553
@ -14,28 +14,6 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
const _ = require('lodash');
|
||||
const { format } = require('prettier');
|
||||
|
||||
// Prettier lazy-loads its parsers, so preload the HTML parser while we know we're not mocked.
|
||||
require('prettier/parser-html');
|
||||
|
||||
function stripWhitespace(str) {
|
||||
// Remove leading whitespace.
|
||||
str = str.replace(/^[\s]+/gm, '');
|
||||
// Remove empty lines.
|
||||
str = str.replace(/^\n$/gm, '');
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function normalizeHtml(str) {
|
||||
str = format(str, {
|
||||
parser: 'html',
|
||||
tabWidth: 2,
|
||||
});
|
||||
|
||||
return stripWhitespace(str);
|
||||
}
|
||||
|
||||
function isInstanceOf(actual, expected) {
|
||||
let actualName;
|
||||
@ -140,12 +118,6 @@ const matcherFuncs = {
|
||||
toBeWholeNumber: (actual) => {
|
||||
return Number.isInteger(actual);
|
||||
},
|
||||
toContainHtml: (actual, expected) => {
|
||||
const actualDiffable = normalizeHtml(actual);
|
||||
const expectedDiffable = normalizeHtml(expected);
|
||||
|
||||
return actualDiffable.includes(expectedDiffable);
|
||||
},
|
||||
toEndWith: (actual, expected) => {
|
||||
return _.isString(actual) && _.isString(expected) && actual.endsWith(expected);
|
||||
},
|
||||
|
||||
22
packages/jsdoc-test-matchers/package-lock.json
generated
22
packages/jsdoc-test-matchers/package-lock.json
generated
@ -9,8 +9,7 @@
|
||||
"version": "0.2.3",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.21",
|
||||
"prettier": "^3.0.3"
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=v18.12.0"
|
||||
@ -20,20 +19,6 @@
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz",
|
||||
"integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==",
|
||||
"bin": {
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
@ -41,11 +26,6 @@
|
||||
"version": "4.17.21",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
||||
},
|
||||
"prettier": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz",
|
||||
"integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,8 +26,7 @@
|
||||
},
|
||||
"type": "commonjs",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.21",
|
||||
"prettier": "^3.0.3"
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=v18.12.0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user