package wegmans import ( "context" "net/url" "testing" ) func TestGetItemPrice_NilBrowser(t *testing.T) { u, _ := url.Parse("https://shop.wegmans.com/product/24921") _, err := DefaultConfig.GetItemPrice(context.Background(), nil, u) if err != ErrNilBrowser { t.Errorf("expected ErrNilBrowser, got %v", err) } } func TestGetItemPrice_NilURL(t *testing.T) { // NilBrowser check comes before NilURL, so we can't test NilURL // independently without a real browser. Verify the error sentinel exists. if ErrNilURL.Error() != "url is nil" { t.Errorf("ErrNilURL = %q, want %q", ErrNilURL.Error(), "url is nil") } } func TestGetItemPrice_ErrorSentinels(t *testing.T) { if ErrInvalidURL.Error() != "invalid url" { t.Errorf("ErrInvalidURL = %q, want %q", ErrInvalidURL.Error(), "invalid url") } if ErrNilBrowser.Error() != "browser is nil" { t.Errorf("ErrNilBrowser = %q, want %q", ErrNilBrowser.Error(), "browser is nil") } } func TestItem_ZeroValue(t *testing.T) { var item Item if item.ID != 0 || item.Name != "" || item.Price != 0 || item.UnitPrice != 0 || item.Unit != "" { t.Error("zero-value Item should have empty/zero fields") } }