package org.richfaces.rendekit;

import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.richfaces.component.UIInplaceInput;
import org.richfaces.renderkit.html.InplaceInputRenderer;

import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

public class InplaceInputRendererTest extends AbstractAjax4JsfTestCase{
	
	private UIInplaceInput iinput;
	private InplaceInputRenderer  renderer;
	
	
	public InplaceInputRendererTest(String name) {
		super(name);
	}
	
	
	public void setUp() throws Exception {
		super.setUp();
		renderer = new InplaceInputRenderer();
	    iinput = (UIInplaceInput)application.createComponent("org.richfaces.InplaceInput");
	    iinput.setValue("New York");
	    facesContext.getViewRoot().getChildren().add(iinput);
	}
	
	public void testRender() throws Exception{
		
		HtmlPage page = renderView();
		assertNotNull(page);
		HtmlElement elem = page.getHtmlElementById(iinput.getClientId(facesContext));
		assertNotNull(elem);
		assertEquals(elem.getTagName(), "span");
	}
}
