From 2c627afbe4eb95e6d697cfe9794fbb21a5ea8dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0nan=C3=A7=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 4 Nov 2024 10:29:35 -0500 Subject: [PATCH] Add TestBrowserContextSetGeolocation --- common/browser_context_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/browser_context_test.go b/common/browser_context_test.go index 7203b191c..c31424192 100644 --- a/common/browser_context_test.go +++ b/common/browser_context_test.go @@ -325,3 +325,23 @@ func TestFilterCookies(t *testing.T) { }) } } + +func TestBrowserContextSetGeolocation(t *testing.T) { + vu := k6test.NewVU(t) + + var opts BrowserContextOptions + err := opts.Parse(vu.Context(), vu.ToSobekValue((struct { + GeoLocation *Geolocation `js:"geolocation"` + }{ + GeoLocation: &Geolocation{ + Latitude: 1.0, + Longitude: 2.0, + Accuracy: 3.0, + }, + }))) + assert.NoError(t, err) + assert.NotNil(t, opts) + assert.Equal(t, 1.0, opts.Geolocation.Latitude) + assert.Equal(t, 2.0, opts.Geolocation.Longitude) + assert.Equal(t, 3.0, opts.Geolocation.Accuracy) +}