/*
* 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.option;
import static br.com.objectos.way.ui.builder.Html.select;
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.HtmlOption;
import br.com.objectos.way.ui.builder.HtmlSelect;
/**
* @author carolene.bertoldi@objectos.com.br (Carolene Reis Silva Bertoldi)
*/
@Test
public class HtmlComboboxTest {
public void select_teste() {
HtmlSelect ui = select().end();
assertThat(ui, hasToString(equalTo("<select></select>")));
}
public void select_name() {
HtmlSelect ui = select()
.name("name")
.end();
assertThat(ui, hasToString(equalTo("<select name=\"name\"></select>")));
}
public void select_style() {
HtmlSelect ui = select()
.styleClass("span2")
.end();
assertThat(ui, hasToString(equalTo("<select class=\"span2\"></select>")));
}
public void option_teste() {
HtmlOption ui = Html.option()
.end();
assertThat(ui, hasToString(equalTo("<option></option>")));
}
public void option_value() {
HtmlOption ui = Html.option()
.value("value")
.end();
assertThat(ui, hasToString(equalTo("<option value=\"value\"></option>")));
}
public void option_text() {
HtmlOption ui = Html.option()
.text("Text")
.end();
assertThat(ui, hasToString(equalTo("<option>Text</option>")));
}
public void combobox_completa() {
String contra = "/html/combobox.html";
String prova = HtmlsFalso.toString(contra);
HtmlSelect ui = select()
.name("name")
.styleClass("span2")
.add(
option()
.value("value")
.text("Text")
.end()
)
.end();
assertThat(ui, hasToString(equalTo(prova)));
}
}