diff --git a/packages/react/tests/e2e-storybook/cypress/integration/LinkList/LinkList.e2e.js b/packages/react/tests/e2e-storybook/cypress/integration/LinkList/LinkList.e2e.js index 6763d928411..c31a75d0220 100644 --- a/packages/react/tests/e2e-storybook/cypress/integration/LinkList/LinkList.e2e.js +++ b/packages/react/tests/e2e-storybook/cypress/integration/LinkList/LinkList.e2e.js @@ -4,7 +4,7 @@ * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ -import getCssPropertyForRule from '../../../../utils/get-css-property-for-rule'; +import getCssPropertyForRule from '../../utils/get-css-property-for-rule'; /** * Sets the correct path diff --git a/packages/react/tests/utils/get-css-property-for-rule.js b/packages/react/tests/e2e-storybook/cypress/utils/get-css-property-for-rule.js similarity index 100% rename from packages/react/tests/utils/get-css-property-for-rule.js rename to packages/react/tests/e2e-storybook/cypress/utils/get-css-property-for-rule.js diff --git a/packages/web-components/tests/e2e-storybook/cypress/integration/link-list/link-list.e2e.js b/packages/web-components/tests/e2e-storybook/cypress/integration/link-list/link-list.e2e.js index 62fd11ce395..e0aa72e5ba3 100644 --- a/packages/web-components/tests/e2e-storybook/cypress/integration/link-list/link-list.e2e.js +++ b/packages/web-components/tests/e2e-storybook/cypress/integration/link-list/link-list.e2e.js @@ -4,7 +4,7 @@ * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ -import getCssPropertyForRule from '../../../../utils/get-css-property-for-rule'; +import getCssPropertyForRule from '../../utils/get-css-property-for-rule'; /** * Sets the correct path diff --git a/packages/web-components/tests/e2e-storybook/cypress/utils/get-css-property-for-rule.js b/packages/web-components/tests/e2e-storybook/cypress/utils/get-css-property-for-rule.js new file mode 100644 index 00000000000..5c27faf1ce5 --- /dev/null +++ b/packages/web-components/tests/e2e-storybook/cypress/utils/get-css-property-for-rule.js @@ -0,0 +1,24 @@ +/** + * Copyright IBM Corp. 2021 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +export default function getCssPropertyForRule(rule, prop, sheets) { + const slen = sheets.length; + for (let i = 0; i < slen; i++) { + let rules; + try { + rules = sheets[i].cssRules; + } catch (e) { + continue; + } + const rlen = rules.length; + for (let j = 0; j < rlen; j++) { + if (rules[j].selectorText === rule) { + return rules[j].style[prop]; + } + } + } +} diff --git a/packages/web-components/tests/utils/get-css-property-for-rule.ts b/packages/web-components/tests/utils/get-css-property-for-rule.ts deleted file mode 100644 index 539f9d3fdbc..00000000000 --- a/packages/web-components/tests/utils/get-css-property-for-rule.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * - * Copyright IBM Corp. 2021 - * - * This source code is licensed under the Apache-2.0 license found in the - * LICENSE file in the root directory of this source tree. - */ - -/** - * @param rule Which elements to target. - * @param prop Which properties to target. - * @param sheets The CSS style sheets. - * @returns the value of the css property from the rule. - */ -function getCssPropertyForRule(rule, prop, sheets) { - const slen = sheets.length; - for (let i = 0; i < slen; i++) { - let rules; - if (sheets[i].cssRules !== undefined) { - rules = sheets[i].cssRules; - const rlen = rules.length; - for (let j = 0; j < rlen; j++) { - if (rules[j].selectorText === rule) { - return rules[j].style[prop]; - } - } - } - } - return false; -} - -export default getCssPropertyForRule;