Skip to content

Commit

Permalink
Merge pull request #23 from jAg-upfort/master
Browse files Browse the repository at this point in the history
fix Fragment.isEmpty(), Fragment.isHidden(),  Fragment.isSignature(), and Fragment.isQuoted()
  • Loading branch information
baptistejamin committed Jul 15, 2024
2 parents 774b813 + ef6fb12 commit e72dd3b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}

Expand Down
20 changes: 10 additions & 10 deletions lib/fragment.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
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() {
return "" === this.getContent.replace(/\n/g, "");
return "" === this.getContent().replace(/\n/g, "");
}

toString() {
return this.getContent();
}
}

module.exports = Fragment;
module.exports = Fragment;
26 changes: 13 additions & 13 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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]));

Expand All @@ -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]));

Expand Down

0 comments on commit e72dd3b

Please sign in to comment.