test: improve test coverage (#6387)

* test: improve test coverage

* fix

* use posixPath
This commit is contained in:
Joshua Chen 2022-01-18 16:29:40 +08:00 committed by GitHub
parent a9810db1cc
commit 62223ee556
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 463 additions and 60 deletions

View file

@ -1,3 +1,4 @@
/* stylelint-disable docusaurus/copyright-header, declaration-block-no-duplicate-custom-properties */
:root {
--color-primary: red;
--color-secondary: green;

View file

@ -1,3 +1,4 @@
/* stylelint-disable docusaurus/copyright-header, declaration-block-no-duplicate-custom-properties */
:root {
--color-primary: red;
--color-primary: red;
@ -5,3 +6,8 @@
--color-primary: blue;
--color-header: gray;
}
.non-root {
--color-primary: red;
--color-primary: red;
}

View file

@ -1,16 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`remove-overridden-custom-properties overridden custom properties should be removed 1`] = `
":root {
"/* stylelint-disable docusaurus/copyright-header, declaration-block-no-duplicate-custom-properties */
:root {
--color-secondary: green;
--color-primary: blue;
--color-header: gray;
}
.non-root {
--color-primary: red;
--color-primary: red;
}
"
`;
exports[`remove-overridden-custom-properties overridden custom properties with \`!important\` rule should not be removed 1`] = `
":root {
"/* stylelint-disable docusaurus/copyright-header, declaration-block-no-duplicate-custom-properties */
:root {
--color-primary: blue;
--color-header: gray !important;
--color-secondary: yellow !important;

View file

@ -22,8 +22,9 @@ module.exports = function creator() {
return;
}
const sameProperties =
decl.parent.nodes.filter((n) => n.prop === decl.prop) || [];
const sameProperties = decl.parent.nodes.filter(
(n) => n.prop === decl.prop,
);
const hasImportantProperties = sameProperties.some((p) =>
Object.prototype.hasOwnProperty.call(p, 'important'),
);