Skip to content

Commit

Permalink
fix: add double quotes for coping locator output & add semicolons in …
Browse files Browse the repository at this point in the history
…Colorized Jdi String
  • Loading branch information
Iogsotot committed Dec 6, 2023
1 parent 1f1cd45 commit aa11323
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
36 changes: 18 additions & 18 deletions src/common/utils/copyToClipboard.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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);
});
};
4 changes: 2 additions & 2 deletions src/features/locators/utils/locatorOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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};`;
};
Expand All @@ -117,7 +117,7 @@ export const renderColorizedJdiString = (
<br />
<span className="jdn__locator_item-type">public</span>
<span>&nbsp;{type}&nbsp;</span>
{name}
{name};
</>
);
};
Expand Down

0 comments on commit aa11323

Please sign in to comment.