feat(jsdoc-test-matchers): improve HTML matcher

This commit is contained in:
Jeff Williams 2023-01-07 07:46:11 -08:00
parent 4d24735cce
commit 4451354eee
No known key found for this signature in database

View File

@ -34,6 +34,12 @@ addMatchers({
return valueName === otherName;
},
toContainHtml(other, value) {
const otherDiffable = diffableHtml(other);
const valueDiffable = diffableHtml(value);
return valueDiffable.includes(otherDiffable);
},
toHaveOwnProperty(other, value) {
return Object.hasOwn(value, other);
},
@ -63,12 +69,6 @@ addMatchers({
return isMatch;
},
toMatchHtml(other, value) {
const otherDiffable = diffableHtml(other);
const valueDiffable = diffableHtml(value);
return otherDiffable.includes(valueDiffable);
},
// The `value` object must have all of the keys and values from the `other` object. The `value`
// object can have additional properties as well. For example, if `other` is `{ a: 1 }`, and
// `value` is `{ a: 1, b: 2 }`, then the objects match.