Search in sources :

Example 6 with Content

use of play.twirl.api.Content in project civiform by seattle-uat.

the class BaseHtmlLayoutTest method addsDefaultContent.

@Test
public void addsDefaultContent() {
    HtmlBundle bundle = layout.getBundle();
    Content content = layout.render(bundle);
    assertThat(content.body()).contains("<!DOCTYPE html><html lang=\"en\">");
    assertThat(content.body()).contains("<link href=\"/assets/stylesheets/tailwind.css\" rel=\"stylesheet\">");
    assertThat(content.body()).contains("<script src=\"/assets/javascripts/main.js\" type=\"text/javascript\"></script>");
    assertThat(content.body()).contains("<script src=\"/assets/javascripts/radio.js\" type=\"text/javascript\"></script>");
    assertThat(content.body()).contains("<main></main>");
}
Also used : Content(play.twirl.api.Content) Test(org.junit.Test)

Example 7 with Content

use of play.twirl.api.Content in project civiform by seattle-uat.

the class HtmlBundleTest method rendersContentInOrder.

@Test
public void rendersContentInOrder() {
    HtmlBundle bundle = new HtmlBundle();
    bundle.addMainContent(div("One"));
    bundle.addMainContent(div("Two"));
    Content content = bundle.render();
    assertThat(content.body()).contains("<main><div>One</div><div>Two</div></main>");
}
Also used : Content(play.twirl.api.Content) Test(org.junit.Test)

Example 8 with Content

use of play.twirl.api.Content in project tutorials by eugenp.

the class ApplicationUnitTest method renderTemplate.

@Test
public void renderTemplate() {
    Content html = views.html.index.render("Your new application is ready.");
    assertEquals("text/html", html.contentType());
    assertTrue(html.body().contains("Your new application is ready."));
}
Also used : Content(play.twirl.api.Content)

Example 9 with Content

use of play.twirl.api.Content in project civiform by seattle-uat.

the class BaseHtmlLayoutTest method canAddContentBefore.

@Test
public void canAddContentBefore() {
    HtmlBundle bundle = new HtmlBundle();
    // Add stylesheet before default.
    Tag linkTag = link().withHref("moose.css").withRel("stylesheet");
    bundle.addStylesheets(linkTag);
    bundle = layout.getBundle(bundle);
    Content content = layout.render(bundle);
    assertThat(content.body()).contains("<!DOCTYPE html><html lang=\"en\">");
    assertThat(content.body()).contains("<link href=\"moose.css\" rel=\"stylesheet\"><link" + " href=\"/assets/stylesheets/tailwind.css\" rel=\"stylesheet\">");
}
Also used : Content(play.twirl.api.Content) Tag(j2html.tags.Tag) Test(org.junit.Test)

Example 10 with Content

use of play.twirl.api.Content in project civiform by seattle-uat.

the class HtmlBundleTest method testSetTitle.

@Test
public void testSetTitle() {
    HtmlBundle bundle = new HtmlBundle();
    bundle.setTitle("My title");
    Content content = bundle.render();
    assertThat(content.body()).contains("<title>My title</title>");
}
Also used : Content(play.twirl.api.Content) Test(org.junit.Test)

Aggregations

Content (play.twirl.api.Content)15 Tag (j2html.tags.Tag)7 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)6 TagCreator.div (j2html.TagCreator.div)6 TagCreator.each (j2html.TagCreator.each)6 TagCreator.p (j2html.TagCreator.p)6 ZoneId (java.time.ZoneId)6 Test (org.junit.Test)6 BaseHtmlView (views.BaseHtmlView)6 HtmlBundle (views.HtmlBundle)6 LinkElement (views.components.LinkElement)6 ReferenceClasses (views.style.ReferenceClasses)6 Styles (views.style.Styles)6 Inject (com.google.inject.Inject)5 controllers.admin.routes (controllers.admin.routes)5 TagCreator.h1 (j2html.TagCreator.h1)5 Optional (java.util.Optional)5 Http (play.mvc.Http)4 ProgramDefinition (services.program.ProgramDefinition)4 AdminLayout (views.admin.AdminLayout)4