about summary refs log tree commit diff stats
path: root/attr/attributes_test.go
diff options
context:
space:
mode:
authorMarkus Wüstenberg2020-09-23 20:30:14 +0200
committerGitHub2020-09-23 20:30:14 +0200
commit05c31515c6e5d5a9633b3af4b58eb46456e0632c (patch)
treef7343b7af90620c066eafac48d73c8b72e4c6bb3 /attr/attributes_test.go
parentc832941edb5e896a893c663e83aba7088ea40e6c (diff)
downloadgomponents-05c31515c6e5d5a9633b3af4b58eb46456e0632c.tar.lz
gomponents-05c31515c6e5d5a9633b3af4b58eb46456e0632c.tar.zst
gomponents-05c31515c6e5d5a9633b3af4b58eb46456e0632c.zip
Make attr.Classes a map type (#14)
This makes the usage syntax prettier. Instead of `attr.Classes(map[string]bool{})`, we can just use `attr.Classes{}`.
Diffstat (limited to 'attr/attributes_test.go')
-rw-r--r--attr/attributes_test.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/attr/attributes_test.go b/attr/attributes_test.go
index 0ad8c4e..9c7ece7 100644
--- a/attr/attributes_test.go
+++ b/attr/attributes_test.go
@@ -21,11 +21,18 @@ func TestClass(t *testing.T) {
 
 func TestClasses(t *testing.T) {
 	t.Run("given a map, returns sorted keys from the map with value true", func(t *testing.T) {
-		assert.Equal(t, ` class="boheme-hat hat partyhat"`, attr.Classes(map[string]bool{
+		assert.Equal(t, ` class="boheme-hat hat partyhat"`, attr.Classes{
 			"boheme-hat": true,
 			"hat":        true,
 			"partyhat":   true,
 			"turtlehat":  false,
-		}))
+		})
+	})
+
+	t.Run("also works with fmt", func(t *testing.T) {
+		a := attr.Classes{"hat": true}
+		if a.String() != ` class="hat"` {
+			t.FailNow()
+		}
 	})
 }