package ii

import (
	"net/http"
	"testing"
)

func TestNewFormHandler(t *testing.T) {
	itemInfo, err := ReadFile("_test/http.xml")
	if err != nil {
		t.Error(err)
		return
	}
	mux := http.NewServeMux()

	items := &ItemIndex{
		itemMap: map[string]*ItemInfo{
			itemInfo.Name.ItemName(): itemInfo,
		},
	}
	mux.Handle("/getCode", NewFormHandler(items))
	if err = http.ListenAndServe(":8082", mux); err != nil {
		t.Error(err)
	}
}
