]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Implement tests
authorParis <paris@sourcelair.com>
Fri, 10 Jun 2016 13:35:56 +0000 (16:35 +0300)
committerParis <paris@sourcelair.com>
Fri, 10 Jun 2016 13:35:56 +0000 (16:35 +0300)
src/xterm.js
test/test.js

index ce0a246cb643eb48c4a4467e90b3f29c31d9511d..273fdca5315501b094f81f42e1d7a1353ddc9ded 100644 (file)
      *   1. stripping all trailing white spaces
      *   2. converting all non-breaking spaces to regular spaces
      * @param {string} text The copied text that needs processing for storing in clipboard
+     * @returns {string}
      * @static
      */
        Terminal.prepareCopiedTextForClipboard = function (text) {
index e603d65fc7fa0b600a506f092e1d6e06f90eb547..ffbc285f73473376d6666348b197d611180f42aa 100644 (file)
@@ -54,4 +54,18 @@ describe('xterm.js', function() {
       assert.equal(xterm.evaluateKeyEscapeSequence({ ctrlKey: true, keyCode: 39 }).key, '\x1b[5C'); // CSI 5 C
     });
   });
+
+  describe('evaluateCopiedTextProcessing', function () {
+    it('should strip trailing whitespaces and replace nbsps with spaces', function () {
+                       var nonBreakingSpace = String.fromCharCode(160),
+          copiedText = 'echo' + nonBreakingSpace + 'hello' + nonBreakingSpace,
+          processedText = Terminal.prepareCopiedTextForClipboard(copiedText);
+
+      // No trailing spaces
+      assert.equal(processedText.match(/\s+$/), null);
+
+      // No non-breaking space
+      assert.equal(processedText.indexOf(nonBreakingSpace), -1);
+    });
+  });
 });