Package org.openmrs.module.htmlformentry.widget

Source Code of org.openmrs.module.htmlformentry.widget.DateWidgetTest

package org.openmrs.module.htmlformentry.widget;

import org.junit.Test;
import org.openmrs.module.htmlformentry.FormEntryContext;

import java.text.SimpleDateFormat;
import java.util.Date;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class DateWidgetTest {

    @Test
    public void testHidden() throws Exception {
        Date date = new SimpleDateFormat("yyyy-MM-dd").parse("2014-10-01");

        DateWidget widget = new DateWidget();
        widget.setHidden(true);
        widget.setInitialValue(date);

        FormEntryContext formEntryContext = mock(FormEntryContext.class);
        when(formEntryContext.getFieldName(widget)).thenReturn("w1");

        String html = widget.generateHtml(formEntryContext);
        assertThat(html, is("<input type=\"hidden\" name=\"w1\" id=\"w1\" value=\"2014-10-01\" />"));
    }
}
TOP

Related Classes of org.openmrs.module.htmlformentry.widget.DateWidgetTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.