/*
* Copyright 2013 Objectos, Fábrica de Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package br.com.objectos.way.ui.builder;
import static br.com.objectos.way.ui.builder.Html.table;
import static br.com.objectos.way.ui.builder.Html.tbody;
import static br.com.objectos.way.ui.builder.Html.td;
import static br.com.objectos.way.ui.builder.Html.th;
import static br.com.objectos.way.ui.builder.Html.thead;
import static br.com.objectos.way.ui.builder.Html.tr;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasToString;
import org.testng.annotations.Test;
import br.com.objectos.way.ui.builder.Html;
import br.com.objectos.way.ui.builder.HtmlTable;
import br.com.objectos.way.ui.builder.HtmlTbody;
import br.com.objectos.way.ui.builder.HtmlTd;
import br.com.objectos.way.ui.builder.HtmlTh;
import br.com.objectos.way.ui.builder.HtmlThead;
import br.com.objectos.way.ui.builder.HtmlTr;
/**
* @author carolene.bertoldi@objectos.com.br (Carolene Reis Silva Bertoldi)
*/
@Test
public class HtmlTableTest {
public void table_test() {
HtmlTable ui = Html.table().end();
assertThat(ui, hasToString(equalTo("<table></table>")));
}
public void table_class() {
HtmlTable ui = table()
.styleClass("tac")
.end();
assertThat(ui, hasToString(equalTo("<table class=\"tac\"></table>")));
}
public void thead_teste() {
HtmlThead ui = thead().end();
assertThat(ui, hasToString(equalTo("<thead></thead>")));
}
public void th_teste() {
HtmlTh ui = th().end();
assertThat(ui, hasToString(equalTo("<th></th>")));
}
public void tbody_teste() {
HtmlTbody ui = tbody().end();
assertThat(ui, hasToString(equalTo("<tbody></tbody>")));
}
public void tr_teste() {
HtmlTr ui = tr().end();
assertThat(ui, hasToString(equalTo("<tr></tr>")));
}
public void td_teste() {
HtmlTd ui = td().end();
assertThat(ui, hasToString(equalTo("<td></td>")));
}
@Test(enabled = false)
public void html_string() {
String contra = "/tabela-completa.mustache";
String prova = HtmlsFalso.toString(contra);
HtmlTable ui = table()
.add(
thead()
.add(th().end())
.end()
)
.add(
tbody()
.add(td().end())
.end()
)
.end();
assertThat(ui, hasToString(equalTo(prova)));
}
}