PageRenderTime 45ms CodeModel.GetById 33ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/sitebricks/src/test/java/com/google/sitebricks/rendering/control/TextFieldWidgetTest.java

http://github.com/dhanji/sitebricks
Java | 37 lines | 23 code | 9 blank | 5 comment | 1 complexity | 03e02537b983a468024e2759b8783520 MD5 | raw file
 1package com.google.sitebricks.rendering.control;
 2
 3import com.google.sitebricks.MvelEvaluator;
 4import com.google.sitebricks.Respond;
 5import static org.easymock.EasyMock.createMock;
 6
 7import java.util.HashMap;
 8
 9/**
10 * @author Dhanji R. Prasanna (dhanji@gmail.com)
11 */
12public class TextFieldWidgetTest {
13
14//    @Test
15    public final void textTagRender() {
16
17        final String[] out = new String[1];
18        Respond mockRespond = createMock(Respond.class);
19        final String boundTo = "aString";
20
21        new TextFieldWidget(new ProceedingWidgetChain(), "boundTo", new MvelEvaluator())
22                .render(new HashMap<String, Object>() {{
23                    put("boundTo", boundTo);
24                }}, mockRespond);
25
26
27        //assert the validity of the text tag:
28        assert out[0] != null : "Nothing rendered!";
29        String tag = out[0].trim();
30
31        assert tag.startsWith("<input ");
32        assert tag.endsWith(">");
33        assert tag.contains("value=\"" + boundTo + "\"");
34        assert tag.contains("name=\"boundTo\"");
35        assert tag.contains("type=\"text\"");
36    }
37}