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{}`.
1 file changed, 9 insertions(+), 2 deletions(-)
changed files
M attr/attributes_test.go → attr/attributes_test.go
@@ -21,11 +21,18 @@ } 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() + } }) }