package j2html.tags;

import j2html.attributes.*;
import org.junit.*;
import static j2html.TagCreator.*;
import static org.junit.Assert.*;

public class ComplexRenderTest {

    private String renderTest() {
        boolean USER_SHOULD_LOG_IN = true;
        boolean USER_SHOULD_SIGN_UP = false;
        return document().render() +
                html().with(
                        head().with(
                                title().withText("Test")
                        ),
                        body().with(
                                header().with(
                                        h1().with(
                                                text("Test Header "),
                                                a("with link").withHref("http://example.com"),
                                                text(".")
                                        )
                                ),
                                main().with(
                                        h2("Test Form"),
                                        div().with(
                                                input().withType("email").withName("email").withPlaceholder("Email"),
                                                input().withType("password").withName("password").withPlaceholder("Password")
                                        ).condWith(USER_SHOULD_LOG_IN, button().withType("submit").withText("Login")
                                        ).condWith(USER_SHOULD_SIGN_UP, button().withType("submit").withText("Signup")
                                        )
                                ),
                                footer().attr(Attr.CLASS, "footer").condAttr(1 == 1, Attr.ID, "id").withText("Test Footer"),
                                script().withSrc("/testScript.js")
                        )
                ).render();
    }

    @Test
    public void testComplexRender() {
        String expectedResult = "<!DOCTYPE html><html><head><title>Test</title></head><body><header><h1>Test Header <a href=\"http://example.com\">with link</a>.</h1></header><main><h2>Test Form</h2><div><input type=\"email\" name=\"email\" placeholder=\"Email\"><input type=\"password\" name=\"password\" placeholder=\"Password\"><button type=\"submit\">Login</button></div></main><footer class=\"footer\" id=\"id\">Test Footer</footer><script src=\"/testScript.js\"></script></body></html>";
        assertEquals(renderTest(), expectedResult);
    }
}

@@ -15,16 +15,40 @@
 .tags;%0A%0A
+import org.junit.Test;%0A%0A
 import j
@@ -68,64 +68,627 @@
 tes.
-*
+Attr
 ;%0A
+%0A
 import 
-org.junit.*;%0Aimport static j2html.TagCreator.*
+static j2html.TagCreator.a;%0Aimport static j2html.TagCreator.body;%0Aimport static j2html.TagCreator.button;%0Aimport static j2html.TagCreator.div;%0Aimport static j2html.TagCreator.document;%0Aimport static j2html.TagCreator.footer;%0Aimport static j2html.TagCreator.h1;%0Aimport static j2html.TagCreator.h2;%0Aimport static j2html.TagCreator.head;%0Aimport static j2html.TagCreator.header;%0Aimport static j2html.TagCreator.html;%0Aimport static j2html.TagCreator.input;%0Aimport static j2html.TagCreator.main;%0Aimport static j2html.TagCreator.script;%0Aimport static j2html.TagCreator.text;%0Aimport static j2html.TagCreator.title
 ;%0Aim
@@ -720,9 +720,20 @@
 ert.
-*
+assertEquals
 ;%0A%0Ap
@@ -2146,49 +2146,8 @@
 up%22)
-%0A                                        
 )%0A  

Fix imports in rendertest