package services import "testing" /* Import used to write no price at all — "import is not pricing, the merchant sets it". Right about who decides, wrong about what a shopper sees in between: the product went live at ₹0, which on a phone reads as free rather than as unpriced. A product uploaded by sheet carried its price and showed it; the same product imported from the catalogue showed nothing. The catalogue quotes a range as a string, so it has to be read rather than cast. */ func TestARangeGivesItsLowEnd(t *testing.T) { // Too low is a margin the shop notices and corrects; too high is a shopper // quietly deciding the shop is expensive. if got := SuggestedPriceFrom("₹9-11"); got != 9 { t.Errorf("₹9-11 -> %v, want 9", got) } if got := SuggestedPriceFrom("₹75-95"); got != 75 { t.Errorf("₹75-95 -> %v, want 75", got) } } func TestASinglePriceIsReadAsItself(t *testing.T) { if got := SuggestedPriceFrom("₹22"); got != 22 { t.Errorf("₹22 -> %v, want 22", got) } } func TestPaiseSurvive(t *testing.T) { if got := SuggestedPriceFrom("₹12.50 - ₹15.75"); got != 12.5 { t.Errorf("got %v, want 12.5", got) } } func TestOrderInsideTheRangeDoesNotMatter(t *testing.T) { // A range written backwards still has a low end. if got := SuggestedPriceFrom("₹95-75"); got != 75 { t.Errorf("got %v, want 75", got) } } func TestNoPriceMeansNoPrice(t *testing.T) { // 159 of 672 catalogue rows carry no range. Inventing a figure for those // would be worse than showing none — the merchant would never know to look. for _, input := range []string{"", " ", "₹", "price on request", "N/A"} { if got := SuggestedPriceFrom(input); got != 0 { t.Errorf("%q -> %v, want 0", input, got) } } } func TestAZeroInTheRangeIsNotAPrice(t *testing.T) { // "₹0-50" means the low end is unknown, not that the product is free. if got := SuggestedPriceFrom("₹0-50"); got != 50 { t.Errorf("got %v, want 50", got) } }