package com.wizzardo.http.framework.template.taglib;

import com.wizzardo.http.framework.template.*;
import com.wizzardo.http.framework.template.taglib.g.TextArea;
import com.wizzardo.http.framework.template.taglib.g.TextField;
import com.wizzardo.tools.xml.Node;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.util.Collections;

/**
 * Created by wizzardo on 18.05.15.
 */
public class TextAreaTest implements TagTest {

    @Before
    public void setup() {
        TagLib.findTags(Collections.singletonList(TextArea.class));
    }

    @Test
    public void test_1() {
        RenderResult result = prepare("<g:textArea name=\"myField\" value=\"${myValue}\"/>")
                .get(new Model().append("myValue", 1));

        Assert.assertEquals("<textarea name=\"myField\" id=\"myField\">1</textarea>\n", result.toString());
    }

    @Test
    public void test_2() {
        RenderResult result = prepare("<g:textArea name=\"myField\">$myValue</g:textArea>")
                .get(new Model().append("myValue", 1));

        Assert.assertEquals("<textarea name=\"myField\" id=\"myField\">" +
                "1" +
                "</textarea>\n", result.toString());
    }

}

@@ -1041,33 +1041,33 @@
 pend(%22myValue%22, 
-1
+2
 ));%0A%0A        Ass
@@ -1147,17 +1147,369 @@
        %22
-1
+2%22 +%0A                %22%3C/textarea%3E%5Cn%22, result.toString());%0A    %7D%0A%0A    @Test%0A    public void test_3() %7B%0A        RenderResult result = prepare(%22%3Cg:textArea name=%5C%22myField%5C%22 id=%5C%22myId%5C%22%3E$myValue%3C/g:textArea%3E%22)%0A                .get(new Model().append(%22myValue%22, 3));%0A%0A        Assert.assertEquals(%22%3Ctextarea name=%5C%22myField%5C%22 id=%5C%22myId%5C%22%3E%22 +%0A                %223
 %22 +%0A    

improve tests coverage