Files
2026-05-12 11:25:32 +02:00

24 lines
649 B
Go

package handlers
import (
"net/http/httptest"
"testing"
pscatalog "git.ma-al.com/goc_marek/ps_shop/internal/prestashop/catalog"
)
func TestAssignMarketSwitchLinksUsesCountryCurrencyID(t *testing.T) {
req := httptest.NewRequest("GET", "https://shop.example.com/pl/product/test", nil)
locale := pscatalog.HeaderLocaleData{
Countries: []pscatalog.LocaleOption{
{ID: 36, Code: "PL", CurrencyID: 6, Label: "Polska PLN"},
},
}
assignMarketSwitchLinks(req, &locale)
if got := locale.Countries[0].URL; got != "/pl/product/test?market=36%3APL%3A6" {
t.Fatalf("market url = %q, want %q", got, "/pl/product/test?market=36%3APL%3A6")
}
}