@@ -101,6 +101,47 @@ def test_does_not_modify_input_string
101101 assert_equal "The Quick Brown Fox Jumps Over The Lazy Dog" , original
102102 end
103103
104+ def test_returns_only_the_visible_fragments_as_a_string
105+ reply = email ( :email_2_1 )
106+ assert_equal reply . fragments . select { |r | !r . hidden? } . map { |r | r . to_s } . join ( "\n " ) . rstrip , reply . visible_text
107+ end
108+
109+ def test_parse_out_just_top_for_outlook_reply
110+ body = IO . read EMAIL_FIXTURE_PATH . join ( "email_2_1.txt" ) . to_s
111+ assert_equal "Outlook with a reply" , EmailReplyParser . parse_reply ( body )
112+ end
113+
114+ def test_parse_out_sent_from_iPhone
115+ body = IO . read EMAIL_FIXTURE_PATH . join ( "email_iPhone.txt" ) . to_s
116+ assert_equal "Here is another email" , EmailReplyParser . parse_reply ( body )
117+ end
118+
119+ def test_parse_out_sent_from_BlackBerry
120+ body = IO . read EMAIL_FIXTURE_PATH . join ( "email_BlackBerry.txt" ) . to_s
121+ assert_equal "Here is another email" , EmailReplyParser . parse_reply ( body )
122+ end
123+
124+ def test_parse_out_send_from_multiword_mobile_device
125+ body = IO . read EMAIL_FIXTURE_PATH . join ( "email_multi_word_sent_from_my_mobile_device.txt" ) . to_s
126+ assert_equal "Here is another email" , EmailReplyParser . parse_reply ( body )
127+ end
128+
129+ def test_do_not_parse_out_send_from_in_regular_sentence
130+ body = IO . read EMAIL_FIXTURE_PATH . join ( "email_sent_from_my_not_signature.txt" ) . to_s
131+ assert_equal "Here is another email\n \n Sent from my desk, is much easier then my mobile phone." , EmailReplyParser . parse_reply ( body )
132+ end
133+
134+ def test_retains_bullets
135+ body = IO . read EMAIL_FIXTURE_PATH . join ( "email_bullets.txt" ) . to_s
136+ assert_equal "test 2 this should list second\n \n and have spaces\n \n and retain this formatting\n \n \n - how about bullets\n - and another" ,
137+ EmailReplyParser . parse_reply ( body )
138+ end
139+
140+ def test_parse_reply
141+ body = IO . read EMAIL_FIXTURE_PATH . join ( "email_1_2.txt" ) . to_s
142+ assert_equal EmailReplyParser . read ( body ) . visible_text , EmailReplyParser . parse_reply ( body )
143+ end
144+
104145 def email ( name )
105146 body = IO . read EMAIL_FIXTURE_PATH . join ( "#{ name } .txt" ) . to_s
106147 EmailReplyParser . read body
0 commit comments