package de.codescape.bitvunit.model;

import com.gargoylesoftware.htmlunit.html.HtmlElement;
import org.junit.Test;

import java.util.List;

import static de.codescape.bitvunit.util.html.HtmlPageUtil.toHtmlPage;
import static org.junit.Assert.*;

public class PageTest {

    @Test
    public void findAllHeadingTagsReturnsHeadingsOfEveryLevel() throws Exception {
        String content = "<html><body>" + "<h1>First Heading</h1>" + "<h2>Second Heading</h2>" +
                "<h3>Third Heading</h3>" + "<h4>Fourth Heading</h4>" + "<h5>Fifth Heading</h5>" +
                "<h6>Sixth Heading</h6>" + "</body></html>";
        List<HtmlElement> headings = new Page(toHtmlPage(content)).findAllHeadingTags();
        assertNotNull(headings);
        assertEquals(6, headings.size());

        for (int i = 1; i < 7; i++) {
            boolean found = false;
            for (HtmlElement heading : headings) {
                if (heading.getTagName().equals("h" + i)) {
                    found = true;
                }
            }
            assertTrue(found);
        }
    }

}

@@ -86,16 +86,69 @@
 lement;%0A
+import com.gargoylesoftware.htmlunit.html.HtmlTitle;%0A
 import o
@@ -318,16 +318,83 @@
 Test %7B%0A%0A
+    public static final String EXPECTED_TITLE = %22Expected Title%22;%0A%0A
     @Tes
@@ -1197,10 +1197,358 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void findTitleTagShouldReturnTheCorrectTitle() %7B%0A        String content = %22%3Chtml%3E%3Chead%3E%3Ctitle%3E%22 + EXPECTED_TITLE + %22%3C/title%3E%3Cbody%3E%3C/body%3E%3C/html%3E%22;%0A        HtmlTitle titleTag = new Page(toHtmlPage(content)).findTitleTag();%0A        assertNotNull(titleTag);%0A        assertEquals(EXPECTED_TITLE, titleTag.getTextContent());%0A    %7D%0A%0A
 %7D%0A

add test for finding the title on the page under test