From aa1132354387d4e0eabadf476c5011ec1e4dd9ec Mon Sep 17 00:00:00 2001 From: Anna Iustus Date: Wed, 6 Dec 2023 12:38:26 +0100 Subject: [PATCH] fix: add double quotes for coping locator output & add semicolons in Colorized Jdi String --- src/common/utils/copyToClipboard.ts | 36 +++++++++---------- src/features/locators/utils/locatorOutput.tsx | 4 +-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/common/utils/copyToClipboard.ts b/src/common/utils/copyToClipboard.ts index f217bd38..3cccaf5b 100644 --- a/src/common/utils/copyToClipboard.ts +++ b/src/common/utils/copyToClipboard.ts @@ -1,21 +1,3 @@ -export const copyToClipboard = (value: string | string[]) => { - const clipboard = navigator.clipboard; - const valueString: string = valueToString(value); - - if (!clipboard) { - console.error('Clipboard API is not supported in this browser.'); - return; - } - - // eslint-disable-next-line prettier/prettier - clipboard - .writeText(valueString) - .catch((error) => { - console.warn('Error copying text to clipboard:', error); - deprecatedCopyToClipboard(valueString); - }); -}; - const valueToString = (value: string | string[]) => { if (Array.isArray(value)) { return value.join('\n'); @@ -37,3 +19,21 @@ const deprecatedCopyToClipboard = (value: string) => { console.warn('Second Error copying text to clipboard:', err); } }; + +export const copyToClipboard = (value: string | string[]) => { + const clipboard = navigator.clipboard; + const valueString: string = valueToString(value); + + if (!clipboard) { + console.error('Clipboard API is not supported in this browser.'); + return; + } + + // eslint-disable-next-line prettier/prettier + clipboard + .writeText(valueString) + .catch((error) => { + console.warn('Error copying text to clipboard:', error); + deprecatedCopyToClipboard(valueString); + }); +}; diff --git a/src/features/locators/utils/locatorOutput.tsx b/src/features/locators/utils/locatorOutput.tsx index 066e7f75..0eed2ff4 100644 --- a/src/features/locators/utils/locatorOutput.tsx +++ b/src/features/locators/utils/locatorOutput.tsx @@ -95,7 +95,7 @@ export const getLocatorString = ( type: ElementLibrary | ElementClass, name: string, ): string => { - const locatorOutput = `'${locator.output}'`; + const locatorOutput = `"${locator.output}"`; return `${annotationType}(${getLocatorPrefix(annotationType, locatorType)}${locatorOutput})\npublic ${type} ${name};`; }; @@ -117,7 +117,7 @@ export const renderColorizedJdiString = (
public  {type}  - {name} + {name}; ); };