Custom clipboard object added to the unit tests

This commit is contained in:
ribas160 2025-01-10 16:23:04 +02:00
parent 6c651ea676
commit 48eb6ef87a
4 changed files with 34 additions and 50 deletions

View file

@ -5459,9 +5459,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
copyIcon,
successIcon,
shortcutHint,
url,
testMode,
testClipboard;
url;
/**
* Handle copy to clipboard button click
@ -5542,11 +5540,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
* @function
*/
function saveToClipboard(text) {
if (testMode) {
testClipboard = text;
} else {
navigator.clipboard.writeText(text);
}
navigator.clipboard.writeText(text);
};
/**
@ -5612,35 +5606,6 @@ jQuery.PrivateBin = (function($, RawDeflate) {
url = newUrl;
};
/**
* Enable test mode, using for unit tests
*
* @name CopyToClipboard.testMode
* @function
*/
me.enableTestMode = function () {
testMode = true;
};
/**
* Read text from user's clipboard
*
* @name CopyToClipboard.readFromClipboard
* @function
* @returns {string}
*/
me.readFromClipboard = function () {
let clipboardData = "";
if (testMode) {
clipboardData = testClipboard;
} else {
clipboardData = navigator.clipboard.readText();
}
return clipboardData;
};
/**
* Initialize
*