package attribute_test import ( "testing" "gitlab.codemonkeysoftware.net/b/hatmill" "gitlab.codemonkeysoftware.net/b/hatmill/attribute" ) func testAttribValue(t *testing.T, attrib hatmill.Attrib, expectedValue string) { t.Helper() if attrib.ValueString() != expectedValue { t.Fatalf("expected attribute value to be %#v, but got %#v", expectedValue, attrib.ValueString()) } } func TestString(t *testing.T) { const s = "abcdefg" testAttribValue(t, attribute.Id(s), s) } func TestBool(t *testing.T) { testAttribValue(t, attribute.Disabled(), "") } func TestExplicitBool(t *testing.T) { t.Run("true", func(t *testing.T) { testAttribValue(t, attribute.Draggable(true), "true") }) t.Run("false", func(t *testing.T) { testAttribValue(t, attribute.Draggable(false), "false") }) } func TestInt(t *testing.T) { t.Run("zero", func(t *testing.T) { testAttribValue(t, attribute.Height(0), "0") }) t.Run("positive", func(t *testing.T) { testAttribValue(t, attribute.Height(45), "45") }) t.Run("negative", func(t *testing.T) { testAttribValue(t, attribute.Tabindex(-45), "-45") }) }