From 5e48bd544e9c53ad315c73d9b1a526a16278dc4c Mon Sep 17 00:00:00 2001 From: Alon Dahari Date: Tue, 4 Jun 2024 16:15:16 +0100 Subject: [PATCH] Test new behaiour --- test/test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test.js b/test/test.js index 0730b81..a5b358e 100644 --- a/test/test.js +++ b/test/test.js @@ -101,6 +101,20 @@ describe('quote-selection', function () { assert.equal(textarea.value, 'Has text\n\n> bold\n\n') }) + + it('allows processing the quoted text before inserting it', function () { + const el = document.querySelector('#quotable') + const selection = window.getSelection() + window.getSelection = () => createSelection(selection, el) + + const textarea = document.querySelector('#not-hidden-textarea') + const quote = new Quote() + quote.processSelectionTextFn = text => text.replace('Quotable', 'replaced') + + quote.insert(textarea) + + assert.equal(textarea.value, 'Has text\n\n> Test replaced text, bold.\n\n') + }) }) describe('with markdown enabled', function () {