mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-10-05 18:34:20 +02:00
Custom clipboard object added to the unit tests
This commit is contained in:
parent
6c651ea676
commit
48eb6ef87a
4 changed files with 34 additions and 50 deletions
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue