35 lines
808 B
Go
35 lines
808 B
Go
package attribute_test
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"git.codemonkeysoftware.net/b/hatmill/attribute"
|
|
"git.codemonkeysoftware.net/b/hatmill/element"
|
|
)
|
|
|
|
func TestStepValue(t *testing.T) {
|
|
t.Run(`String returns "any" for StepAny`, func(t *testing.T) {
|
|
actual := attribute.StepAny().String()
|
|
expected := "any"
|
|
expectEqualStrings(t, actual, expected)
|
|
})
|
|
|
|
t.Run("String returns valid float for StepFloat", func(t *testing.T) {
|
|
actual := attribute.StepFloat(5.5).String()
|
|
expected := "5.5"
|
|
expectEqualStrings(t, actual, expected)
|
|
})
|
|
}
|
|
|
|
func ExampleStep() {
|
|
s1 := attribute.Step(attribute.StepAny())
|
|
s2 := attribute.Step(attribute.StepFloat(0.5))
|
|
e := element.Div()(
|
|
element.Input(s1),
|
|
element.Input(s2),
|
|
)
|
|
e.WriteTo(os.Stdout)
|
|
// Output: <div><input step='any'><input step='0.5'></div>
|
|
}
|