diff --git a/test/ModuleTest.js b/test/ModuleTest.js new file mode 100644 index 0000000..6cf75a2 --- /dev/null +++ b/test/ModuleTest.js @@ -0,0 +1,154 @@ +/** + * This file is part of node-email-reply-parser. + * For the full license information, please see the LICENSE file distributed with this package. + */ + +var util = require("./utils"); +//var describe = require("mocha").describe; +//var it = require("mocha").it; +var assert = require("assert"); +var _ = require("lodash"); +var replyParser = require("../index"); + +describe('index.js', function () { + it('should return a defined email object with no visible text when given null', function () { + //noinspection JSCheckFunctionSignatures + var email = replyParser(null); + + assert.equal(email.getVisibleText(), '', 'Visible text not empty'); + }); + + it('should return a defined email object with no visible text when given an empty string', function () { + var email = replyParser(''); + + assert.equal(email.getVisibleText(), '', 'Visible text not empty'); + }); + + it('should process sent from iPhone messages', function () { + var fixture = util.getFixture('email_iphone.txt'); + var email = replyParser(fixture, true); + + assert.equal(email, 'Here is another email', 'Visible text is incorrect'); + }); + + it('should process sent from Blackberry messages', function () { + var fixture = util.getFixture('email_blackberry.txt'); + var email = replyParser(fixture, true); + + assert.equal(email, 'Here is another email', 'Visible text is incorrect'); + }); + + it('should process sent from multiword device messages', function () { + var fixture = util.getFixture('email_multi_word_sent_from_my_mobile_device.txt'); + var email = replyParser(fixture, true); + + assert.equal(email, 'Here is another email', 'Visible text is incorrect'); + }); + + it('should process sent from not a signature message', function () { + var fixture = util.getFixture('email_sent_from_my_not_signature.txt'); + var email = replyParser(fixture, true); + + assert.equal(email, 'Here is another email\n\nSent from my desk, is much easier then my mobile phone.', 'Visible text is incorrect'); + }); + + it('should find just the top part of an Outlook message', function () { + var fixture = util.getFixture('email_2_1.txt'); + var email = replyParser(fixture, true); + + assert.equal(email, 'Outlook with a reply', 'Visible text is incorrect'); + }); + + it('should retain bullets', function () { + var fixture = util.getFixture('email_bullets.txt'); + var email = replyParser(fixture, true); + + assert.equal(email, 'test 2 this should list second\n\nand have spaces\n\nand retain this formatting\n\n\n - how about bullets\n - and another', 'Visible text is incorrect'); + }); + + it('should parse unquoted reply', function () { + var fixture = util.getFixture('email_unquoted_reply.txt'); + var email = replyParser(fixture, true); + + assert.equal(email, 'This is my reply.', 'Visible text is incorrect'); + }); + + it('should preserve newlines in email threads', function () { + var fixture = util.getFixture('email_thread.txt'); + var email = replyParser(fixture); + + var expectedText = + "On Nov 21, 2014, at 10:18, John Doe wrote:\n" + + "> Ok. Thanks.\n" + + ">\n" + + "> On Nov 21, 2014, at 9:26, Jim Beam wrote:\n" + + ">\n" + + ">>> On Nov 20, 2014, at 11:03 AM, John Doe wrote:\n" + + ">>>\n" + + ">>> if you take a look at a short video from attachment, why full-typed filename does not stay in CMD+T pane?\n" + + ">>> When I type last character, it is not shown anymore.\n" + + ">>\n" + + ">> We think we’ve tracked down the cause of this issue, write back if you see the issue after the next update. (Which will be out shortly.)\n" + + ">>\n" + + ">> --\n" + + ">> Jim Beam – Acme Corp\n" + + ">>\n" + + ">\n"; + + assert.equal(email.getFragments()[1].getContent(), expectedText, 'Second fragment is incorrect'); + }); + + it('should parse a reply', function () { + var fixture = util.getFixture('email_2.txt'); + var email = replyParser(fixture); + + var expectedText = + "Hi,\n" + + "You can list the keys for the bucket and call delete for each. Or if you\n" + + "put the keys (and kept track of them in your test) you can delete them\n" + + "one at a time (without incurring the cost of calling list first.)\n" + + "Something like:\n" + + " String bucket = \"my_bucket\";\n" + + " BucketResponse bucketResponse = riakClient.listBucket(bucket);\n" + + " RiakBucketInfo bucketInfo = bucketResponse.getBucketInfo();\n" + + " for(String key : bucketInfo.getKeys()) {\n" + + " riakClient.delete(bucket, key);\n" + + " }\n" + + "would do it.\n" + + "See also\n" + + "http://wiki.basho.com/REST-API.html#Bucket-operations\n" + + "which says\n" + + "\"At the moment there is no straightforward way to delete an entire\n" + + "Bucket. There is, however, an open ticket for the feature. To delete all\n" + + "the keys in a bucket, you’ll need to delete them all individually.\"\n"; + + assert.equal(email.getVisibleText(), expectedText, 'Did not get expected visible body'); + }); + + it('should parse a reply as text only when asked', function () { + var fixture = util.getFixture('email_2.txt'); + var email = replyParser(fixture, true); + + var expectedText = + "Hi,\n" + + "You can list the keys for the bucket and call delete for each. Or if you\n" + + "put the keys (and kept track of them in your test) you can delete them\n" + + "one at a time (without incurring the cost of calling list first.)\n" + + "Something like:\n" + + " String bucket = \"my_bucket\";\n" + + " BucketResponse bucketResponse = riakClient.listBucket(bucket);\n" + + " RiakBucketInfo bucketInfo = bucketResponse.getBucketInfo();\n" + + " for(String key : bucketInfo.getKeys()) {\n" + + " riakClient.delete(bucket, key);\n" + + " }\n" + + "would do it.\n" + + "See also\n" + + "http://wiki.basho.com/REST-API.html#Bucket-operations\n" + + "which says\n" + + "\"At the moment there is no straightforward way to delete an entire\n" + + "Bucket. There is, however, an open ticket for the feature. To delete all\n" + + "the keys in a bucket, you’ll need to delete them all individually.\"\n"; + + assert.equal(email, expectedText, 'Did not get expected visible body'); + }); +}); \ No newline at end of file diff --git a/test/ParserTest.js b/test/ParserTest.js new file mode 100644 index 0000000..af9906e --- /dev/null +++ b/test/ParserTest.js @@ -0,0 +1,435 @@ +/** + * This file is part of node-email-reply-parser. + * For the full license information, please see the LICENSE file distributed with this package. + */ + +var util = require("./utils"); +//var describe = require("mocha").describe; +//var it = require("mocha").it; +var assert = require("assert"); +var _ = require("lodash"); +var Parser = require("../lib/Parser"); + +const COMMON_FIRST_FRAGMENT = "Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus.\n" + + "Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante.\n" + + "Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum.\n" + + "Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna,\n" + + "et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh."; + +const DATE_FORMATS = [ + 'On Tue, 2011-03-01 at 18:02 +0530, Abhishek Kona wrote:', + '2014-03-20 8:48 GMT+01:00 Rémi Dolan :', // Gmail + '2014-03-20 20:48 GMT+01:00 Rémi Dolan :', // Gmail + '2014-03-09 20:48 GMT+01:00 Rémi Dolan :', // Gmail + 'Le 19 mars 2014 10:37, Cédric Lombardot a écrit :', // Gmail + 'El 19/03/2014 11:34, Juan Pérez escribió:', // Gmail in spanish + 'W dniu 7 stycznia 2015 15:24 użytkownik Paweł Brzoski napisał:', //Gmail in polish + 'Le 19/03/2014 11:34, Georges du chemin a écrit :', // Thunderbird + 'W dniu 2015-01-07 14:23, pbrzoski91@gmail.com pisze: ', // Thunderbird in polish + 'Den 08/06/2015 kl. 21.21 skrev Test user :', // Danish + 'Am 25.06.2015 um 10:55 schrieb Test user:', // German 1 + 'Test user schrieb:', // German 2 + '在 2016年11月8日,下午2:23,Test user 写道:', // Chinese Apple Mail iPhone parsed html + '2016. 11. 8. 오후 12:39 Test user 작성:', // Korean Apple Mail iPhone + '2016/11/08 14:26、Test user のメッセージ:' // Japanese Apple Mail iPhone +]; + +describe('the Parser', function () { + it('should parse a simple body', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_1.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments.length, 3, 'Wrong number of fragments'); + + for (var fragment of fragments) { + assert.equal(fragment.isQuoted(), false, 'Fragment should not be quoted'); + } + + assert.equal(fragments[0].isSignature(), false, 'First fragment is not supposed to be a signature'); + assert.equal(fragments[1].isSignature(), true, 'Second fragment is supposed to be a signature'); + assert.equal(fragments[2].isSignature(), true, 'Third fragment is supposed to be a signature'); + + assert.equal(fragments[0].isHidden(), false, 'First fragment should be visible'); + assert.equal(fragments[1].isHidden(), true, 'Second fragment should not be visible'); + assert.equal(fragments[2].isHidden(), true, 'Third fragment should not be visible'); + + var fragMessage = + "Hi folks\n\n" + + "What is the best way to clear a Riak bucket of all key, values after\n" + + "running a test?\n" + + "I am currently using the Java HTTP API.\n\n"; + var fragSignature = + "_______________________________________________\n" + + "riak-users mailing list\n" + + "riak-users@lists.basho.com\n" + + "http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com\n"; + + assert.equal(fragments[0].getContent(), fragMessage, 'First fragment has the wrong content'); + assert.equal(fragments[1].getContent(), "-Abhishek Kona\n\n", 'Second fragment has the wrong content'); + assert.equal(fragments[2].getContent(), fragSignature, 'Third fragment has the wrong content'); + }); + + it('should not hang on to email instances', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_1.txt"); + + var email1 = parser.parse(fixture); + var email2 = parser.parse(fixture); + + assert.notStrictEqual(email1, email2, 'Email instances should not be the same'); + assert.deepEqual(email1, email2, 'Email instances should have been the same'); // should be same content + }); + + it('should read the first post in a message', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_3.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments.length, 5, 'Wrong number of fragments'); + + assert.equal(fragments[0].isQuoted(), false, 'First fragment should not be quoted'); + assert.equal(fragments[1].isQuoted(), false, 'Second fragment should not be quoted'); + assert.equal(fragments[2].isQuoted(), true, 'Third fragment should be quoted'); + assert.equal(fragments[3].isQuoted(), false, 'Fourth fragment should not be quoted'); + assert.equal(fragments[4].isQuoted(), false, 'Fifth fragment should not be quoted'); + + assert.equal(fragments[0].isSignature(), false, 'First fragment should not be a signature'); + assert.equal(fragments[1].isSignature(), true, 'Second fragment should be a signature'); + assert.equal(fragments[2].isSignature(), false, 'Third fragment should not be a signature'); + assert.equal(fragments[3].isSignature(), false, 'Fourth fragment should not be a signature'); + assert.equal(fragments[4].isSignature(), true, 'Fifth fragment should be a signature'); + + assert.equal(fragments[0].isHidden(), false, 'First fragment should not be hidden'); + assert.equal(fragments[1].isHidden(), true, 'Second fragment should be hidden'); + assert.equal(fragments[2].isHidden(), true, 'Third fragment should be hidden'); + assert.equal(fragments[3].isHidden(), true, 'Fourth fragment should be hidden'); + assert.equal(fragments[4].isHidden(), true, 'Fifth fragment should be hidden'); + + assert.equal(/^Oh thanks.\n\nHaving/.test(fragments[0].getContent()), true, 'First fragment has wrong content match'); + assert.equal(/^-A/.test(fragments[1].getContent()), true, 'Second fragment has wrong content match'); + assert.equal(/^On [^:]+:/.test(fragments[2].getContent()), true, 'Third fragment has wrong content match'); + assert.equal(/^_/.test(fragments[4].getContent()), true, 'Fifth fragment has wrong content match'); + }); + + it('should read the last post', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_2.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments.length, 6, 'Wrong number of fragments'); + + assert.equal(fragments[0].getContent(), 'Hi,', 'First fragment has the wrong content'); + assert.equal(/^On [^:]+:/.test(fragments[1].getContent()), true, 'Second fragment has the wrong content'); + assert.equal(/^You can list/.test(fragments[2].getContent()), true, 'Third fragment has the wrong content'); + assert.equal(/^>/.test(fragments[3].getContent()), true, 'Fourth fragment has the wrong content'); + assert.equal(/^_/.test(fragments[5].getContent()), true, 'Sixth fragment has the wrong content'); + }); + + it('should recognize date strings above quotes', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_4.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(/^Awesome/.test(fragments[0].getContent()), true, 'First fragment has the wrong content'); + assert.equal(/^On/.test(fragments[1].getContent()), true, 'Second fragment has the wrong content'); + assert.equal(/Loader/.test(fragments[1].getContent()), true, 'Second fragment has the wrong content'); + }); + + it('should not modify the input string', function () { + var parser = new Parser(); + var input = 'The Quick Brown Fox Jumps Over The Lazy Dog'; + var email = parser.parse(input); + + assert.strictEqual('The Quick Brown Fox Jumps Over The Lazy Dog', input); + }); + + it('should correctly handle complex bodies with only one fragment', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_5.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(1, fragments.length, 'Wrong number of fragments'); + }); + + it('should deal with multiline reply headers', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_6.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(/^I get/.test(fragments[0].getContent()), true, 'First fragment has the wrong content'); + assert.equal(/^On/.test(fragments[1].getContent()), true, 'Second fragment has the wrong content'); + assert.equal(/Was this/.test(fragments[1].getContent()), true, 'Second fragment has the wrong content'); + }); + + it('should handle Italian emails', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_7.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle Dutch emails', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_8.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle signatures with equal signs', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_9.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle hotmail emails', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_10.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle whitespace before the reply header', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_11.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle square brackets in emails', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_12.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle da into Italian', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_13.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle Polish email headers', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_14.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle "sent from my" signatures', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_15.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle Polish email headers with Dnia and Napisala', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_16.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle Polish email headers with date in ISO8061', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_17.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should handle English Outlook emails', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_18.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments[0].getContent().trim(), COMMON_FIRST_FRAGMENT, "Doesn't match common fragment"); + }); + + it('should return only visible fragments in getVisibleText()', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_2_1.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + var visibleFragments = _.filter(fragments, f => !f.isHidden()); + var visibleText = visibleFragments.join('\n'); + + assert.equal(email.getVisibleText(), visibleText, "Visible text doesn't match"); + }); + + it('should read email with correct signature', function () { + var parser = new Parser(); + var fixture = util.getFixture("correct_sig.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments.length, 2, 'Wrong number of fragments'); + + assert.equal(fragments[0].isQuoted(), false, "First fragment is not supposed to be quoted"); + assert.equal(fragments[1].isQuoted(), false, "Second fragment is not supposed to be quoted"); + + assert.equal(fragments[0].isSignature(), false, "First fragment is not supposed to be a signature"); + assert.equal(fragments[1].isSignature(), true, "Second fragment is supposed to be a signature"); + + assert.equal(fragments[0].isHidden(), false, "First fragment is not supposed to be hidden"); + assert.equal(fragments[1].isHidden(), true, "Second fragment is supposed to be hidden"); + + assert.equal(/^--\nrick/.test(fragments[1].getContent()), true, "Second fragment has wrong signature"); + }); + + it('should read email with correct signature with no empty line above it', function () { + var parser = new Parser(); + var fixture = util.getFixture("sig_no_empty_line.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments.length, 2, 'Wrong number of fragments'); + + assert.equal(fragments[0].isQuoted(), false, "First fragment is not supposed to be quoted"); + assert.equal(fragments[1].isQuoted(), false, "Second fragment is not supposed to be quoted"); + + assert.equal(fragments[0].isSignature(), false, "First fragment is not supposed to be a signature"); + assert.equal(fragments[1].isSignature(), true, "Second fragment is supposed to be a signature"); + + assert.equal(fragments[0].isHidden(), false, "First fragment is not supposed to be hidden"); + assert.equal(fragments[1].isHidden(), true, "Second fragment is supposed to be hidden"); + + assert.equal(/^--\nrick/.test(fragments[1].getContent()), true, "Second fragment has wrong signature"); + }); + + it('should read email with correct signature with whitespace', function () { + var parser = new Parser(); + var fixture = util.getFixture("correct_sig.txt").replace('--', '-- '); // we add the space here so that IDEs don't remove it accidentally + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments.length, 2, 'Wrong number of fragments'); + + assert.equal(fragments[0].isQuoted(), false, "First fragment is not supposed to be quoted"); + assert.equal(fragments[1].isQuoted(), false, "Second fragment is not supposed to be quoted"); + + assert.equal(fragments[0].isSignature(), false, "First fragment is not supposed to be a signature"); + assert.equal(fragments[1].isSignature(), true, "Second fragment is supposed to be a signature"); + + assert.equal(fragments[0].isHidden(), false, "First fragment is not supposed to be hidden"); + assert.equal(fragments[1].isHidden(), true, "Second fragment is supposed to be hidden"); + + assert.equal(/^-- \nrick/.test(fragments[1].getContent()), true, "Second fragment has wrong signature"); + }); + + it('should read email with correct signature with no empty line above it and whitespace', function () { + var parser = new Parser(); + var fixture = util.getFixture("sig_no_empty_line.txt").replace('--', '-- '); // we add the space here so that IDEs don't remove it accidentally + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments.length, 2, 'Wrong number of fragments'); + + assert.equal(fragments[0].isQuoted(), false, "First fragment is not supposed to be quoted"); + assert.equal(fragments[1].isQuoted(), false, "Second fragment is not supposed to be quoted"); + + assert.equal(fragments[0].isSignature(), false, "First fragment is not supposed to be a signature"); + assert.equal(fragments[1].isSignature(), true, "Second fragment is supposed to be a signature"); + + assert.equal(fragments[0].isHidden(), false, "First fragment is not supposed to be hidden"); + assert.equal(fragments[1].isHidden(), true, "Second fragment is supposed to be hidden"); + + assert.equal(/^-- \nrick/.test(fragments[1].getContent()), true, "Second fragment has wrong signature"); + }); + + it('should not handle "one" as "on"', function () { + var parser = new Parser(); + var fixture = util.getFixture("email_one_is_not_on.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(/One outstanding question/.test(fragments[0].getContent()), true, "First fragment has wrong content"); + assert.equal(/^On Oct 1, 2012/.test(fragments[1].getContent()), true, "Second fragment has wrong content"); + }); + + it('should use custom quote header regex when given', function () { + var regex = [/^(\d{4}([\S\s]*)rta:)$/m]; + var parser = new Parser(null, null, regex); + var fixture = util.getFixture("email_custom_quote_header.txt"); + var email = parser.parse(fixture); + + assert.equal(email.getVisibleText(), "Thank you!", "Visible text is incorrect"); + }); + + it('should use custom quote header regex when given (second)', function () { + var regex = [/^(From: [\S\s]+ [\S\s]+test@webdomain\.com[\S\s]+)/m]; + var parser = new Parser(null, null, regex); + var fixture = util.getFixture("email_customer_quote_header_2.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments.length, 2, 'Wrong number of fragments'); + + assert.equal(email.getVisibleText(), "Thank you very much", "Visible text is incorrect"); + assert.equal(fragments[1].isHidden(), true, "Second fragment should be hidden"); + assert.equal(fragments[1].isQuoted(), true, "Second fragment should be quoted"); + }); + + it('should use custom quote header regex when given (third)', function () { + var regex = [/^(De : [\S\s]+ [\S\s]+someone@yahoo[\S\s]fr\.com[\S\s]+)/m]; + var parser = new Parser(null, null, regex); + var fixture = util.getFixture("email_customer_quote_header_3.txt"); + var email = parser.parse(fixture); + var fragments = email.getFragments(); + + assert.equal(fragments.length, 2, 'Wrong number of fragments'); + + var visibleText = "bonjour,\n" + + "je n'ai pas eu de retour sur ma précision..\n" + + "merci d'avance"; + + assert.equal(email.getVisibleText(), visibleText, "Visible text is incorrect"); + assert.equal(fragments[1].isHidden(), true, "Second fragment should be hidden"); + assert.equal(fragments[1].isQuoted(), true, "Second fragment should be quoted"); + }); + + function testDateFormat(format) { + it('should handle date format: ' + format, function () { + var parser = new Parser(); + var fixture = util.getFixture("email_with_date_headers.txt").replace('[DATE]', format); + var email = parser.parse(fixture); + + assert.equal(email.getVisibleText(), "Thank you very much", "Visible text is incorrect"); + }); + } + + for (var format of DATE_FORMATS) { + testDateFormat(format); + } +}); \ No newline at end of file diff --git a/test/fixtures/correct_sig.txt b/test/fixtures/correct_sig.txt new file mode 100644 index 0000000..647cae8 --- /dev/null +++ b/test/fixtures/correct_sig.txt @@ -0,0 +1,4 @@ +this is an email with a correct -- signature. + +-- +rick diff --git a/test/fixtures/email_1.txt b/test/fixtures/email_1.txt new file mode 100644 index 0000000..fd56b25 --- /dev/null +++ b/test/fixtures/email_1.txt @@ -0,0 +1,13 @@ +Hi folks + +What is the best way to clear a Riak bucket of all key, values after +running a test? +I am currently using the Java HTTP API. + +-Abhishek Kona + + +_______________________________________________ +riak-users mailing list +riak-users@lists.basho.com +http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com diff --git a/test/fixtures/email_10.txt b/test/fixtures/email_10.txt new file mode 100644 index 0000000..2fc6138 --- /dev/null +++ b/test/fixtures/email_10.txt @@ -0,0 +1,14 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +De : Company Questions +Envoyé le :jeudi 15 décembre 2016 09:35 +À : someone@hotmail.fr +Objet :Curabitur dictum aliquet mollis. + +Etiam non sagittis orci, non rutrum urna. Suspendisse ut sapien id dolor posuere placerat et vitae felis. +Fusce mollis condimentum nulla. Donec luctus justo eu purus placerat, non suscipit ex facilisis. +Sed risus lorem, porta eget imperdiet in, euismod eu nisl. Integer vel metus felis. \ No newline at end of file diff --git a/test/fixtures/email_11.txt b/test/fixtures/email_11.txt new file mode 100644 index 0000000..ef05f72 --- /dev/null +++ b/test/fixtures/email_11.txt @@ -0,0 +1,14 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + + De : Company Questions + Envoyé le :jeudi 15 décembre 2016 09:35 + À : someone@hotmail.fr + Objet :Curabitur dictum aliquet mollis. + +Etiam non sagittis orci, non rutrum urna. Suspendisse ut sapien id dolor posuere placerat et vitae felis. +Fusce mollis condimentum nulla. Donec luctus justo eu purus placerat, non suscipit ex facilisis. +Sed risus lorem, porta eget imperdiet in, euismod eu nisl. Integer vel metus felis. \ No newline at end of file diff --git a/test/fixtures/email_12.txt b/test/fixtures/email_12.txt new file mode 100644 index 0000000..2e6a97f --- /dev/null +++ b/test/fixtures/email_12.txt @@ -0,0 +1,14 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +Van: Company Questions [mailto:questions@company.com] +Verzonden: maandag 5 december 2016 17:00 +Aan: someone@hotmail.fr +Onderwerp: Curabitur dictum aliquet mollis. + +Etiam non sagittis orci, non rutrum urna. Suspendisse ut sapien id dolor posuere placerat et vitae felis. +Fusce mollis condimentum nulla. Donec luctus justo eu purus placerat, non suscipit ex facilisis. +Sed risus lorem, porta eget imperdiet in, euismod eu nisl. Integer vel metus felis. \ No newline at end of file diff --git a/test/fixtures/email_13.txt b/test/fixtures/email_13.txt new file mode 100644 index 0000000..3223c08 --- /dev/null +++ b/test/fixtures/email_13.txt @@ -0,0 +1,14 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +Da: Company Questions +Inviato: martedì 3 gennaio 2017 10:35 +A: someone@hotmail.it +Oggetto: Curabitur dictum aliquet mollis. + +Etiam non sagittis orci, non rutrum urna. Suspendisse ut sapien id dolor posuere placerat et vitae felis. +Fusce mollis condimentum nulla. Donec luctus justo eu purus placerat, non suscipit ex facilisis. +Sed risus lorem, porta eget imperdiet in, euismod eu nisl. Integer vel metus felis. \ No newline at end of file diff --git a/test/fixtures/email_14.txt b/test/fixtures/email_14.txt new file mode 100644 index 0000000..da6e59f --- /dev/null +++ b/test/fixtures/email_14.txt @@ -0,0 +1,11 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +W dniu 2017-01-09 11:59:39 użytkownik Company Questions napisał: + +Etiam non sagittis orci, non rutrum urna. Suspendisse ut sapien id dolor posuere placerat et vitae felis. +Fusce mollis condimentum nulla. Donec luctus justo eu purus placerat, non suscipit ex facilisis. +Sed risus lorem, porta eget imperdiet in, euismod eu nisl. Integer vel metus felis. \ No newline at end of file diff --git a/test/fixtures/email_15.txt b/test/fixtures/email_15.txt new file mode 100644 index 0000000..f4eab59 --- /dev/null +++ b/test/fixtures/email_15.txt @@ -0,0 +1,11 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +Sent from my Wiko RIDGE FAB 4G + +Etiam non sagittis orci, non rutrum urna. Suspendisse ut sapien id dolor posuere placerat et vitae felis. +Fusce mollis condimentum nulla. Donec luctus justo eu purus placerat, non suscipit ex facilisis. +Sed risus lorem, porta eget imperdiet in, euismod eu nisl. Integer vel metus felis. \ No newline at end of file diff --git a/test/fixtures/email_16.txt b/test/fixtures/email_16.txt new file mode 100644 index 0000000..d65a45e --- /dev/null +++ b/test/fixtures/email_16.txt @@ -0,0 +1,11 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +Dnia 27 grudnia 2016 12:08 Company Questions napisał(a): + +Etiam non sagittis orci, non rutrum urna. Suspendisse ut sapien id dolor posuere placerat et vitae felis. +Fusce mollis condimentum nulla. Donec luctus justo eu purus placerat, non suscipit ex facilisis. +Sed risus lorem, porta eget imperdiet in, euismod eu nisl. Integer vel metus felis. \ No newline at end of file diff --git a/test/fixtures/email_17.txt b/test/fixtures/email_17.txt new file mode 100644 index 0000000..da6e59f --- /dev/null +++ b/test/fixtures/email_17.txt @@ -0,0 +1,11 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +W dniu 2017-01-09 11:59:39 użytkownik Company Questions napisał: + +Etiam non sagittis orci, non rutrum urna. Suspendisse ut sapien id dolor posuere placerat et vitae felis. +Fusce mollis condimentum nulla. Donec luctus justo eu purus placerat, non suscipit ex facilisis. +Sed risus lorem, porta eget imperdiet in, euismod eu nisl. Integer vel metus felis. \ No newline at end of file diff --git a/test/fixtures/email_18.txt b/test/fixtures/email_18.txt new file mode 100644 index 0000000..f0c518a --- /dev/null +++ b/test/fixtures/email_18.txt @@ -0,0 +1,14 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +From: John Jung +Date: Thursday, July 7, 2016 at 3:10 PM +To: Lucy Corpora +Subject: Re: + +Etiam non sagittis orci, non rutrum urna. Suspendisse ut sapien id dolor posuere placerat et vitae felis. +Fusce mollis condimentum nulla. Donec luctus justo eu purus placerat, non suscipit ex facilisis. +Sed risus lorem, porta eget imperdiet in, euismod eu nisl. Integer vel metus felis. \ No newline at end of file diff --git a/test/fixtures/email_2.txt b/test/fixtures/email_2.txt new file mode 100644 index 0000000..8697d17 --- /dev/null +++ b/test/fixtures/email_2.txt @@ -0,0 +1,51 @@ +Hi, +On Tue, 2011-03-01 at 18:02 +0530, Abhishek Kona wrote: +> Hi folks +> +> What is the best way to clear a Riak bucket of all key, values after +> running a test? +> I am currently using the Java HTTP API. + +You can list the keys for the bucket and call delete for each. Or if you +put the keys (and kept track of them in your test) you can delete them +one at a time (without incurring the cost of calling list first.) + +Something like: + + String bucket = "my_bucket"; + BucketResponse bucketResponse = riakClient.listBucket(bucket); + RiakBucketInfo bucketInfo = bucketResponse.getBucketInfo(); + + for(String key : bucketInfo.getKeys()) { + riakClient.delete(bucket, key); + } + + +would do it. + +See also + +http://wiki.basho.com/REST-API.html#Bucket-operations + +which says + +"At the moment there is no straightforward way to delete an entire +Bucket. There is, however, an open ticket for the feature. To delete all +the keys in a bucket, you’ll need to delete them all individually." + +> +> -Abhishek Kona +> +> +> _______________________________________________ +> riak-users mailing list +> riak-users@lists.basho.com +> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com + + + + +_______________________________________________ +riak-users mailing list +riak-users@lists.basho.com +http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com diff --git a/test/fixtures/email_2_1.txt b/test/fixtures/email_2_1.txt new file mode 100644 index 0000000..9bce623 --- /dev/null +++ b/test/fixtures/email_2_1.txt @@ -0,0 +1,24 @@ +Outlook with a reply + + + ------------------------------ + +*From:* Google Apps Sync Team [mailto:mail-noreply@google.com] +*Sent:* Thursday, February 09, 2012 1:36 PM +*To:* jow@xxxx.com +*Subject:* Google Apps Sync was updated! + + + +Dear Google Apps Sync user, + +Google Apps Sync for Microsoft Outlook® was recently updated. Your computer +now has the latest version (version 2.5). This release includes bug fixes +to improve product reliability. For more information about these and other +changes, please see the help article here: + +http://www.google.com/support/a/bin/answer.py?answer=153463 + +Sincerely, + +The Google Apps Sync Team. diff --git a/test/fixtures/email_3.txt b/test/fixtures/email_3.txt new file mode 100644 index 0000000..f7ae6f3 --- /dev/null +++ b/test/fixtures/email_3.txt @@ -0,0 +1,55 @@ +Oh thanks. + +Having the function would be great. + +-Abhishek Kona + +On 01/03/11 7:07 PM, Russell Brown wrote: +> Hi, +> On Tue, 2011-03-01 at 18:02 +0530, Abhishek Kona wrote: +>> Hi folks +>> +>> What is the best way to clear a Riak bucket of all key, values after +>> running a test? +>> I am currently using the Java HTTP API. +> You can list the keys for the bucket and call delete for each. Or if you +> put the keys (and kept track of them in your test) you can delete them +> one at a time (without incurring the cost of calling list first.) +> +> Something like: +> +> String bucket = "my_bucket"; +> BucketResponse bucketResponse = riakClient.listBucket(bucket); +> RiakBucketInfo bucketInfo = bucketResponse.getBucketInfo(); +> +> for(String key : bucketInfo.getKeys()) { +> riakClient.delete(bucket, key); +> } +> +> +> would do it. +> +> See also +> +> http://wiki.basho.com/REST-API.html#Bucket-operations +> +> which says +> +> "At the moment there is no straightforward way to delete an entire +> Bucket. There is, however, an open ticket for the feature. To delete all +> the keys in a bucket, you’ll need to delete them all individually." +> +>> -Abhishek Kona +>> +>> +>> _______________________________________________ +>> riak-users mailing list +>> riak-users@lists.basho.com +>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com +> + + +_______________________________________________ +riak-users mailing list +riak-users@lists.basho.com +http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com diff --git a/test/fixtures/email_4.txt b/test/fixtures/email_4.txt new file mode 100644 index 0000000..c79ae14 --- /dev/null +++ b/test/fixtures/email_4.txt @@ -0,0 +1,5 @@ +Awesome! I haven't had another problem with it. + +On Aug 22, 2011, at 7:37 PM, defunkt wrote: + +> Loader seems to be working well. diff --git a/test/fixtures/email_5.txt b/test/fixtures/email_5.txt new file mode 100644 index 0000000..2498775 --- /dev/null +++ b/test/fixtures/email_5.txt @@ -0,0 +1,15 @@ +One: Here's what I've got. + +- This would be the first bullet point that wraps to the second line +to the next +- This is the second bullet point and it doesn't wrap +- This is the third bullet point and I'm having trouble coming up with enough +to say +- This is the fourth bullet point + +Two: +- Here is another bullet point +- And another one + +This is a paragraph that talks about a bunch of stuff. It goes on and on +for a while. diff --git a/test/fixtures/email_6.txt b/test/fixtures/email_6.txt new file mode 100644 index 0000000..8f8f564 --- /dev/null +++ b/test/fixtures/email_6.txt @@ -0,0 +1,15 @@ +I get proper rendering as well. + +Sent from a magnificent torch of pixels + +On Dec 16, 2011, at 12:47 PM, Corey Donohoe + +wrote: + +> Was this caching related or fixed already? I get proper rendering here. +> +> ![](https://img.skitch.com/20111216-m9munqjsy112yqap5cjee5wr6c.jpg) +> +> --- +> Reply to this email directly or view it on GitHub: +> https://github.com/github/github/issues/2278#issuecomment-3182418 diff --git a/test/fixtures/email_7.txt b/test/fixtures/email_7.txt new file mode 100644 index 0000000..6c10f83 --- /dev/null +++ b/test/fixtures/email_7.txt @@ -0,0 +1,41 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +Il giovedì 8 dicembre 2016, Company Questions +ha scritto: +> Ciao Lorem +> +> Dino ha risposto alla tua domanda: +> +> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pharetra d +ignissim odio? +> +> +> Vestibulum nec dui luctus, rhoncus tortor in +> +> +> "Lorem +> +> Maecenas tempor libero nec orci scelerisque porta a quis orci. +rhoncus tortor in. +> + +-- + +____________________________________________________________________ + +Le informazioni contenute in questo messaggio e negli allegati sono +riservate e per uso esclusivo del destinatario. + +Persone diverse dal destinatario non possono copiare o consegnare il +messaggio a terzi, né trattare i dati qui contenuti. + +Se ricevete questo messaggio per errore, Vi preghiamo di restituircelo +immediatamente e di cancellarlo. Grazie. + +MyCompany - 123456 ROMA +tel 0123-456789 fax 0123-456789 e-mail info@client.it +_____________________________________________________________________ diff --git a/test/fixtures/email_8.txt b/test/fixtures/email_8.txt new file mode 100644 index 0000000..cc4c41e --- /dev/null +++ b/test/fixtures/email_8.txt @@ -0,0 +1,14 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +Op 12 december 2016 19:05 schreef Company Questions < +questions@company.com>: + +> Beste Praesent +> Jeroen, winkel Kortrijk heeft je vraag beantwoord: +> "In efficitur augue ac tristique ullamcorper. Aenean tincidunt ornare diam, +eget accumsan est viverra quis. Pellentesque" +> \ No newline at end of file diff --git a/test/fixtures/email_9.txt b/test/fixtures/email_9.txt new file mode 100644 index 0000000..1d17c5c --- /dev/null +++ b/test/fixtures/email_9.txt @@ -0,0 +1,18 @@ +Fusce bibendum, quam hendrerit sagittis tempor, dui turpis tempus erat, pharetra sodales ante sem sit amet metus. +Nulla malesuada, orci non vulputate lobortis, massa felis pharetra ex, convallis consectetur ex libero eget ante. +Nam vel turpis posuere, rhoncus ligula in, venenatis orci. Duis interdum venenatis ex a rutrum. +Duis ut libero eu lectus consequat consequat ut vel lorem. Vestibulum convallis lectus urna, +et mollis ligula rutrum quis. Fusce sed odio id arcu varius aliquet nec nec nibh. + +======================================== + +Message du : 12/12/2016 13:20 +De : "Company Questions " +A : maecenas@somewhere.fr +Copie à : +Sujet :  vitae porta purus rutrum eget ! + +Proin cursus, nibh sed posuere hendrerit, dui mauris scelerisque erat, vel tempus mauris odio eu lectus. +Nulla facilisi. Praesent pellentesque vehicula ante. Aenean posuere placerat magna porta mollis. +Fusce interdum ante ac purus ultricies, sed rhoncus ligula ultricies. Ut eleifend augue at laoreet bibendum. +Nullam mollis euismod erat, convallis porta velit commodo eu. diff --git a/test/fixtures/email_blackberry.txt b/test/fixtures/email_blackberry.txt new file mode 100644 index 0000000..9cf4824 --- /dev/null +++ b/test/fixtures/email_blackberry.txt @@ -0,0 +1,3 @@ +Here is another email + +Sent from my BlackBerry diff --git a/test/fixtures/email_bullets.txt b/test/fixtures/email_bullets.txt new file mode 100644 index 0000000..668cd38 --- /dev/null +++ b/test/fixtures/email_bullets.txt @@ -0,0 +1,22 @@ +test 2 this should list second + +and have spaces + +and retain this formatting + + + - how about bullets + - and another + + +On Fri, Feb 24, 2012 at 10:19 AM, wrote: + +> Give us an example of how you applied what they learned to achieve +> something in your organization + + + + +-- + +*Joe Smith | Director, Product Management* diff --git a/test/fixtures/email_custom_quote_header.txt b/test/fixtures/email_custom_quote_header.txt new file mode 100644 index 0000000..849b1d0 --- /dev/null +++ b/test/fixtures/email_custom_quote_header.txt @@ -0,0 +1,18 @@ +Thank you! + +2013.02.08. 7:31 keltezéssel, "Gyõrvári Eszter" írta: +> http://www.imdb.com/title/tt2017109/ +> +> +> I really like your products! +> +> +> +> +> +> + +-- +Győrvári Gábor - Scr34m +scr34m@gmail.com + diff --git a/test/fixtures/email_customer_quote_header_2.txt b/test/fixtures/email_customer_quote_header_2.txt new file mode 100644 index 0000000..b8e7fda --- /dev/null +++ b/test/fixtures/email_customer_quote_header_2.txt @@ -0,0 +1,8 @@ +Thank you very much. + + + +From: somedude [mailto:test@webdomain.com] +Sent: Tuesday, 14 May 2013 6:18 AM +To: Developer +Subject: You have a new message diff --git a/test/fixtures/email_customer_quote_header_3.txt b/test/fixtures/email_customer_quote_header_3.txt new file mode 100644 index 0000000..af0d637 --- /dev/null +++ b/test/fixtures/email_customer_quote_header_3.txt @@ -0,0 +1,11 @@ +bonjour, +je n'ai pas eu de retour sur ma précision.. +merci d'avance + + De : Someone Somewhere + À : mycompany + Envoyé le : Mercredi 30 novembre 2016 10h30 + Objet : Re: Vous avez reçu une réponse à votre question ! + +bonjour, +ici dans la description cdt diff --git a/test/fixtures/email_iphone.txt b/test/fixtures/email_iphone.txt new file mode 100644 index 0000000..e5d2169 --- /dev/null +++ b/test/fixtures/email_iphone.txt @@ -0,0 +1,3 @@ +Here is another email + +Sent from my iPhone diff --git a/test/fixtures/email_multi_word_sent_from_my_mobile_device.txt b/test/fixtures/email_multi_word_sent_from_my_mobile_device.txt new file mode 100644 index 0000000..c9f89e2 --- /dev/null +++ b/test/fixtures/email_multi_word_sent_from_my_mobile_device.txt @@ -0,0 +1,3 @@ +Here is another email + +Sent from my Verizon Wireless BlackBerry diff --git a/test/fixtures/email_one_is_not_on.txt b/test/fixtures/email_one_is_not_on.txt new file mode 100644 index 0000000..ffff964 --- /dev/null +++ b/test/fixtures/email_one_is_not_on.txt @@ -0,0 +1,10 @@ +Thank, this is really helpful. + +One outstanding question I had: + +Locally (on development), when I run... + +On Oct 1, 2012, at 11:55 PM, Dave Tapley wrote: + +> The good news is that I've found a much better query for lastLocation. +> diff --git a/test/fixtures/email_sent_from_my_not_signature.txt b/test/fixtures/email_sent_from_my_not_signature.txt new file mode 100644 index 0000000..37d1469 --- /dev/null +++ b/test/fixtures/email_sent_from_my_not_signature.txt @@ -0,0 +1,3 @@ +Here is another email + +Sent from my desk, is much easier then my mobile phone. diff --git a/test/fixtures/email_thread.txt b/test/fixtures/email_thread.txt new file mode 100644 index 0000000..7e5e59d --- /dev/null +++ b/test/fixtures/email_thread.txt @@ -0,0 +1,21 @@ +This is new email reply in thread from bellow. + +On Nov 21, 2014, +at 10:18, +John Doe wrote: + +> Ok. Thanks. +> +> On Nov 21, 2014, at 9:26, Jim Beam wrote: +> +>>> On Nov 20, 2014, at 11:03 AM, John Doe wrote: +>>> +>>> if you take a look at a short video from attachment, why full-typed filename does not stay in CMD+T pane? +>>> When I type last character, it is not shown anymore. +>> +>> We think we’ve tracked down the cause of this issue, write back if you see the issue after the next update. (Which will be out shortly.) +>> +>> -- +>> Jim Beam – Acme Corp +>> +> \ No newline at end of file diff --git a/test/fixtures/email_unquoted_reply.txt b/test/fixtures/email_unquoted_reply.txt new file mode 100644 index 0000000..4843a0d --- /dev/null +++ b/test/fixtures/email_unquoted_reply.txt @@ -0,0 +1,5 @@ +This is my reply. + +On Nov 26, 2013 you wrote: + +This is my quote. \ No newline at end of file diff --git a/test/fixtures/email_with_date_headers.txt b/test/fixtures/email_with_date_headers.txt new file mode 100644 index 0000000..01ea5b9 --- /dev/null +++ b/test/fixtures/email_with_date_headers.txt @@ -0,0 +1,5 @@ +Thank you very much. + +[DATE] + +This is my previous mail diff --git a/test/fixtures/sig_no_empty_line.txt b/test/fixtures/sig_no_empty_line.txt new file mode 100644 index 0000000..d730f22 --- /dev/null +++ b/test/fixtures/sig_no_empty_line.txt @@ -0,0 +1,3 @@ +this is an email with a signature with no empty line above. +-- +rick diff --git a/test/utils.js b/test/utils.js new file mode 100644 index 0000000..0489a31 --- /dev/null +++ b/test/utils.js @@ -0,0 +1,20 @@ +/** + * This file is part of node-email-reply-parser. + * For the full license information, please see the LICENSE file distributed with this package. + */ + +var fs = require('fs'); +var path = require('path'); + +/** + * Gets the content of a fixture + * @param {string} name the name of the fixture to load + * @returns {string} the fixture contents + */ +function getFixture(name) { + return fs.readFileSync(path.join(__dirname, 'fixtures', name), 'utf8'); +} + +module.exports = { + getFixture: getFixture +}; \ No newline at end of file