From ffe6d9db9cd416fab5ce9b4aca4149bf8a77dcea Mon Sep 17 00:00:00 2001 From: madflow Date: Sun, 20 Aug 2023 12:17:14 +0200 Subject: [PATCH] fix input type month --- element_test.go | 20 +++++++++++++++++++- fixtures/input.html | 14 ++++++++++++++ lib/js/helper.go | 2 +- lib/js/helper.js | 2 +- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/element_test.go b/element_test.go index e55e977c..5b91041e 100644 --- a/element_test.go +++ b/element_test.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "errors" + "fmt" "image/color" "image/png" "os" @@ -11,13 +12,14 @@ import ( "testing" "time" + "github.com/ysmood/gson" + "github.com/go-rod/rod" "github.com/go-rod/rod/lib/cdp" "github.com/go-rod/rod/lib/devices" "github.com/go-rod/rod/lib/input" "github.com/go-rod/rod/lib/proto" "github.com/go-rod/rod/lib/utils" - "github.com/ysmood/gson" ) func TestGetElementPage(t *testing.T) { @@ -325,6 +327,22 @@ func TestInputTime(t *testing.T) { g.True(p.MustHas("[event=input-datetime-local-change]")) } + { + el = p.MustElement("[type=time]") + el.MustInputTime(now) + + g.Eq(el.MustText(), fmt.Sprintf("%d:%d", now.Hour(), now.Minute())) + g.True(p.MustHas("[event=input-time-change]")) + } + + { + el = p.MustElement("[type=month]") + el.MustInputTime(now) + + g.Eq(el.MustText(), now.Format("2006-01")) + g.True(p.MustHas("[event=input-month-change]")) + } + g.Panic(func() { g.mc.stubErr(1, proto.RuntimeCallFunctionOn{}) el.MustInputTime(now) diff --git a/fixtures/input.html b/fixtures/input.html index 33970cae..6c08aaf2 100644 --- a/fixtures/input.html +++ b/fixtures/input.html @@ -25,6 +25,20 @@
+ + +
+ + + +
+