package edu.chl.proton.model;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertTrue;

/**
 * @author Mickaela
 * Created by Mickaela on 2017-05-14.
 */
public class MarkdownTest {

    private List<String> lines = new ArrayList<>();
    private Markdown markdown;


    @Test public void getHTMLTest() {
        String str = "##The story of an hour\rIt was her sister *Josephine* who told her, " +
                "in broken sentences; veiled **hints** that revealed in half " +
                "concealing.\rHer husband's friend *Richards* was there, too, " +
                "near her.\r> It was he who had been in the newspaper office " +
                "when intelligence of the railroad disaster was received, " +
                "with Brently Mallard's name leading ***the list of killed:***\r" +
                "He had only taken the time to assure himself of its truth by a " +
                "second [telegram](link to stuff), and had ![hastened](dunno) to forestall any less careful," +
                " less tender friend in bearing the sad message.\r";

        String[] original = str.split("\r");

        for(String s : original){
            this.lines.add(s);
        }

        markdown = new Markdown();
        markdown.setText(lines);

        String outcome = "<h2>The story of an hour</h2>\rIt was her sister <i>Josephine</i> who told her, " +
                "in broken sentences; veiled <b>hints</b> that revealed in half " +
                "concealing.\r Her husband's friend <i>Richards</i> was there, too, " +
                "near her.\r<blockquote>> It was he who had been in the newspaper office</blockquote>\r " +
                "when intelligence of the railroad disaster was received, " +
                "with Brently Mallard's name leading <i><b>the list of killed:</b></i>\r" +
                "He had only taken the time to assure himself of its truth by a " +
                "second <a href=\"link to stuff\">telegram</a>, and had <img src=\"dunno\" alt=\"hastened\"> to forestall any less careful," +
                " less tender friend in bearing the sad message.\r";

        String[] withStyling = outcome.split("\r");
        List<String> tmp = new ArrayList<>();

        for(String s : withStyling){
            tmp.add(s);
        }

        assertTrue("Text should get HTML tags: ", markdown.getHTML().equals(tmp));

    }



}

@@ -1385,16 +1385,40 @@
 ome = %22%3C
+p style=%5C%22width:100%25%5C%22%3E%3C
 h2%3EThe s
@@ -1437,18 +1437,66 @@
 our%3C/h2%3E
-%5Cr
+%3C/p%3E%22 +%0D%0A                %22%3Cp style=%5C%22width:100%25%5C%22%3E
 It was h
@@ -1527,32 +1527,53 @@
 i%3E who told her,
+ in broken sentences;
  %22 +%0D%0A          
@@ -1579,37 +1579,16 @@
        %22
-in broken sentences; 
 veiled %3C
@@ -1625,58 +1625,83 @@
 alf 
-%22 +%0D%0A                %22concealing.%5Cr Her husband's 
+concealing.%3C/p%3E%3Cp style=%5C%22width:100%25%5C%22%3EHer husband's %22 +%0D%0A                %22
 frie
@@ -1739,41 +1739,45 @@
 oo, 
-%22 +%0D%0A                %22near her.%5Cr
+near her.%3C/p%3E%3Cp style=%5C%22width:100%25%5C%22%3E
 %3Cblo
@@ -1784,25 +1784,24 @@
 ckquote%3E
-%3E
  It was 
 he who h
@@ -1784,32 +1784,54 @@
 ckquote%3E It was 
+%22 +%0D%0A                %22
 he who had been 
@@ -1857,46 +1857,9 @@
 fice
-%3C/blockquote%3E%5Cr %22 +%0D%0A                %22
+ 
 when
@@ -1973,14 +1973,11 @@
 ing 
-%3Ci%3E%3Cb%3E
+***
 the 
@@ -1995,18 +1995,28 @@
 led:
-%3C/b%3E%3C/i%3E%5Cr
+***%3C/blockquote%3E%3C/p%3E
 %22 +%0D
@@ -2025,32 +2025,56 @@
                %22
+%3Cp style=%5C%22width:100%25%5C%22%3E
 He had only take
@@ -2112,32 +2112,39 @@
  its truth by a 
+second 
 %22 +%0D%0A           
@@ -2149,23 +2149,16 @@
        %22
-second 
 %3Ca href=
@@ -2201,12 +2201,59 @@
 had 
-%3Cimg
+%22 +%0D%0A                %22%3Cimg style=%5C%22max-width:100%25%5C%22
  src
@@ -2303,32 +2303,38 @@
 ny less careful,
+ less 
 %22 +%0D%0A           
@@ -2331,38 +2331,32 @@
                %22
- less 
 tender friend in
@@ -2384,190 +2384,14 @@
 age.
-%5Cr%22;%0D%0A%0D%0A        String%5B%5D withStyling = outcome.split(%22%5Cr%22);%0D%0A        List%3CString%3E tmp = new ArrayList%3C%3E();%0D%0A%0D%0A        for(String s : withStyling)%7B%0D%0A            tmp.add(s);%0D%0A        %7D
+%3C/p%3E%22;
 %0D%0A%0D%0A
@@ -2470,30 +2470,26 @@
 als(
-tmp
+outcome
 ));%0D%0A
-%0D%0A
     %7D%0D%0A
-%0D%0A%0D%0A%0D%0A
 %7D%0D%0A

fix test