Преглед изворни кода

test: fix CopyToClipboard tests broken by bad merge conflict resolution

The merge of master into js/removeJQuery incorrectly kept old jsverify
code in the Keyboard shortcut hint tests instead of the fast-check
versions from this branch. Also updates the copy-document DOM fixture
to match the current CopyToClipboard.init() which binds #copyShortcutHintBtn.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
rugk пре 1 месец
родитељ
комит
4744841af5
1 измењених фајлова са 28 додато и 35 уклоњено
  1. 28 35
      js/test/CopyToClipboard.js

+ 28 - 35
js/test/CopyToClipboard.js

@@ -18,15 +18,15 @@ describe('CopyToClipboard', function () {
                     document.body.innerHTML = (
                         '<div id="status" class="hidden"></div>' +
                         '<div id="errormessage" class="hidden"></div>' +
-                        '<div id="placeholder"></div>' +
-					'<div id="attachmentPreview" class="hidden"></div>' +
-                    '<h5 id="copyShortcutHint" class="hidden">' +
-						'<small id="copyShortcutHintText"></small>' +
+                        '<div id="placeholder" class="hidden">+++ no document text ' +
+                        '+++</div><div id="prettymessage" class="hidden">' +
+                        '<button type="button" id="prettyMessageCopyBtn"><svg id="copyIcon"></svg>' +
+                        '<svg id="copySuccessIcon"></svg></button><pre ' +
+                        'id="prettyprint" class="prettyprint linenums:1"></pre>' +
+                        '</div><div id="plaintext" class="hidden"></div>' +
+                        '<h5 id="copyShortcutHint" class="hidden">' +
                         '<button type="button" id="copyShortcutHintBtn"></button>' +
-					'</h5>' +
-                    '<div id="prettymessage" class="hidden">' +
-                        '<pre id="prettyprint"></pre>' +
-                        '</div>'
+                        '</h5>'
                     );
 
                     PrivateBin.Alert.init();
@@ -60,15 +60,15 @@ describe('CopyToClipboard', function () {
                     document.body.innerHTML = (
                         '<div id="status" class="hidden"></div>' +
                         '<div id="errormessage" class="hidden"></div>' +
-                        '<div id="placeholder"></div> ' +
-                        '<div id="attachmentPreview" class="hidden"></div>' +
-                    '<h5 id="copyShortcutHint" class="hidden">' +
-                        '<small id="copyShortcutHintText"></small>' +
-						'<button type="button" id="copyShortcutHintBtn"></button>' +
-					'</h5>' +
-                    '<div id="prettymessage" class="hidden">' +
-                        '<pre id="prettyprint"></pre>' +
-                        '</div>'
+                        '<div id="placeholder">+++ no document text ' +
+                        '+++</div><div id="prettymessage" class="hidden">' +
+                        '<button type="button" id="prettyMessageCopyBtn"><svg id="copyIcon"></svg>' +
+                        '<svg id="copySuccessIcon"></svg></button><pre ' +
+                        'id="prettyprint" class="prettyprint linenums:1"></pre>' +
+                        '</div><div id="plaintext" class="hidden"></div>' +
+                        '<h5 id="copyShortcutHint" class="hidden">' +
+                        '<button type="button" id="copyShortcutHintBtn"></button>' +
+                        '</h5>'
                     );
 
                     PrivateBin.Alert.init();
@@ -137,37 +137,30 @@ describe('CopyToClipboard', function () {
     });
 
     describe('Keyboard shortcut hint', function () {
-        jsc.property('Show hint', function () {
-                var clean = jsdom();
-
-                $('body').html('<small id="copyShortcutHintText"></small>');
+        it('shows hint', () => {
+            fc.assert(fc.property(fc.string(),
+                function (text) {
+                    document.body.innerHTML = '<h5 id="copyShortcutHint" class="hidden"></h5>';
 
                     PrivateBin.CopyToClipboard.init();
                     PrivateBin.CopyToClipboard.showKeyboardShortcutHint();
 
-                const keyboardShortcutHint = $('#copyShortcutHintText').text();
-
-                clean();
-
-                    return !hasHidden;
+                    return !document.getElementById('copyShortcutHint').classList.contains('hidden');
                 }
             ));
         });
     });
 
-        jsc.property('Hide hint', function () {
-                var clean = jsdom();
-
-                $('body').html('<small id="copyShortcutHintText">' + text + '</small>');
+    it('Hide hint', () => {
+        fc.assert(fc.property(
+            fc.string({minLength: 1}),
+            function (text) {
+                document.body.innerHTML = '<h5 id="copyShortcutHint"></h5>';
 
                 PrivateBin.CopyToClipboard.init();
                 PrivateBin.CopyToClipboard.hideKeyboardShortcutHint();
 
-                const keyboardShortcutHint = $('#copyShortcutHintText').text();
-
-                clean();
-
-                return hasHidden;
+                return document.getElementById('copyShortcutHint').classList.contains('hidden');
             }
         ));
     });