package hx_vals

import (
	"testing"
)

func TestHxVals(t *testing.T) {
	vals := NewHxVals()
	if vals == nil {
		t.Fatalf("swap==nil")
	}
	if tag := vals.Get("test"); tag != nil {
		t.Fatalf("tag not empty")
	}
	vals.Set("innerHTML", 123)
	if tag := vals.Get("innerHTML"); tag != 123 {
		t.Fatalf("tag bad")
	}
	if len_ := vals.Len(); len_ != 1 {
		t.Fatalf("bad len")
	}
	if str := vals.String(); str != `hx-vals='{"innerHTML":123}'` {
		t.Fatalf("str(%v) is bad", str)
	}
	vals.Del("innerHTML")
	vals.Clear()
	if len_ := vals.Len(); len_ != 0 {
		t.Fatalf("bad len")
	}
}
