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

import com.wizzardo.http.framework.template.*;
import com.wizzardo.http.framework.template.taglib.g.CheckBox;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.util.Collections;

/**
 * Created by wizzardo on 26.05.15.
 */
public class CheckBoxTest implements TagTest {

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

    @Test
    public void test_1() {
        RenderResult result = prepare("<g:checkBox name=\"myCheckbox\" value=\"${true}\"/>").get(new Model());

        Assert.assertEquals("<input type=\"checkbox\" name=\"myCheckbox\" id=\"myCheckbox\" value=\"true\"/>\n", result.toString());
    }

    @Test
    public void test_2() {
        RenderResult result = prepare("<g:checkBox name=\"myCheckbox\" id=\"myCheckbox_${i}\" checked=\"${true}\"/>")
                .get(new Model().append("i", 1));

        Assert.assertEquals("<input type=\"checkbox\" name=\"myCheckbox\" id=\"myCheckbox_1\" checked=\"checked\"/>\n", result.toString());
    }

}

@@ -956,17 +956,17 @@
 nd(%22i%22, 
-1
+2
 ));%0A%0A   
@@ -1052,17 +1052,367 @@
 heckbox_
-1
+2%5C%22 checked=%5C%22checked%5C%22/%3E%5Cn%22, result.toString());%0A    %7D%0A%0A    @Test%0A    public void test_3() %7B%0A        RenderResult result = prepare(%22%3Cg:checkBox name=%5C%22myCheckbox%5C%22 id=%5C%22myCheckbox_$%7Bi%7D%5C%22 checked=%5C%22true%5C%22/%3E%22)%0A                .get(new Model().append(%22i%22, 3));%0A%0A        Assert.assertEquals(%22%3Cinput type=%5C%22checkbox%5C%22 name=%5C%22myCheckbox%5C%22 id=%5C%22myCheckbox_3
 %5C%22 check

improve tests coverage