From 7187418d1a557f273b8d6b0c50ad7b77671da763 Mon Sep 17 00:00:00 2001 From: jAg-upfort <129441823+jAg-upfort@users.noreply.github.com> Date: Wed, 10 Apr 2024 10:05:38 -0700 Subject: [PATCH 1/3] fix Fragment.isEmpty() call replace on the result of calling `this.getContent()` instead of the function itself --- lib/fragment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fragment.js b/lib/fragment.js index 6801a83..23f7d0d 100644 --- a/lib/fragment.js +++ b/lib/fragment.js @@ -23,7 +23,7 @@ class Fragment { } isEmpty() { - return "" === this.getContent.replace(/\n/g, ""); + return "" === this.getContent().replace(/\n/g, ""); } toString() { @@ -31,4 +31,4 @@ class Fragment { } } -module.exports = Fragment; \ No newline at end of file +module.exports = Fragment; From 282e2a1973718ac2997eb6472469ff3f0501d56a Mon Sep 17 00:00:00 2001 From: jAg-upfort <129441823+jAg-upfort@users.noreply.github.com> Date: Wed, 10 Apr 2024 10:08:28 -0700 Subject: [PATCH 2/3] don't override the functions in the constructor --- lib/fragment.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/fragment.js b/lib/fragment.js index 23f7d0d..7ef9e2e 100644 --- a/lib/fragment.js +++ b/lib/fragment.js @@ -1,25 +1,25 @@ class Fragment { constructor(content, isHidden, isSignature, isQuoted) { - this.content = content; - this.isHidden = isHidden; - this.isSignature = isSignature; - this.isQuoted = isQuoted; + this._content = content; + this._isHidden = isHidden; + this._isSignature = isSignature; + this._isQuoted = isQuoted; } isHidden() { - return this.isHidden; + return this._isHidden; } isSignature() { - return this.isSignature; + return this._isSignature; } isQuoted() { - return this.isQuoted; + return this._isQuoted; } getContent() { - return this.content; + return this._content; } isEmpty() { From ef6fb124db9c6480d0966d317c7066f1104ad171 Mon Sep 17 00:00:00 2001 From: josh silver Date: Wed, 10 Apr 2024 11:14:27 -0700 Subject: [PATCH 3/3] fix tests --- lib/email.js | 4 ++-- test/test.js | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/email.js b/lib/email.js index 7955391..c9e4ce2 100644 --- a/lib/email.js +++ b/lib/email.js @@ -9,13 +9,13 @@ class Email { getVisibleText() { return this.filterText((fragment) => { - return !fragment.isHidden; + return !fragment.isHidden(); }); } getQuotedText() { return this.filterText((fragment) => { - return fragment.isQuoted; + return fragment.isQuoted(); }); } diff --git a/test/test.js b/test/test.js index bae9142..edbeff7 100644 --- a/test/test.js +++ b/test/test.js @@ -23,8 +23,8 @@ exports.test_reads_simple_body = function(test){ test.equal(2, reply.fragments.length); - test.deepEqual([false, false], _.map(reply.fragments, function(f) { return f.isQuoted; })); - test.deepEqual([false, true], _.map(reply.fragments, function(f) { return f.isHidden; })); + test.deepEqual([false, false], _.map(reply.fragments, function(f) { return f.isQuoted(); })); + test.deepEqual([false, true], _.map(reply.fragments, function(f) { return f.isHidden(); })); test.equal("Hi folks\n\nWhat is the best way to clear a Riak bucket of all key, values after\nrunning a test?\nI am currently using the Java HTTP API.\n\n-Abhishek Kona\n\n", reply.fragments[0].toString()); @@ -293,11 +293,11 @@ exports.test_email_with_correct_signature = function(test) { let fragments = email.getFragments(); test.equal(2, fragments.length); - test.equal(false, fragments[1].isQuoted); - test.equal(false, fragments[0].isSignature); - test.equal(true, fragments[1].isSignature); - test.equal(false, fragments[0].isHidden); - test.equal(true, fragments[1].isHidden); + test.equal(false, fragments[1].isQuoted()); + test.equal(false, fragments[0].isSignature()); + test.equal(true, fragments[1].isSignature()); + test.equal(false, fragments[0].isHidden()); + test.equal(true, fragments[1].isHidden()); test.equal(true, /^--\nrick/.test(fragments[1])); @@ -310,14 +310,14 @@ exports.test_reads_email_with_signature_with_no_empty_line_above = function(test let fragments = email.getFragments(); test.equal(2, fragments.length); - test.equal(false, fragments[0].isQuoted); - test.equal(false, fragments[1].isQuoted); + test.equal(false, fragments[0].isQuoted()); + test.equal(false, fragments[1].isQuoted()); - test.equal(false, fragments[0].isSignature); - test.equal(true, fragments[1].isSignature); + test.equal(false, fragments[0].isSignature()); + test.equal(true, fragments[1].isSignature()); - test.equal(false, fragments[0].isHidden); - test.equal(true, fragments[1].isHidden); + test.equal(false, fragments[0].isHidden()); + test.equal(true, fragments[1].isHidden()); test.equal(true, /^--\nrick/.test(fragments[1]));