diff --git a/src/__tests__/abbreviateForecast.test.ts b/src/__tests__/abbreviateForecast.test.ts index 32f400a7..1c06a7e5 100644 --- a/src/__tests__/abbreviateForecast.test.ts +++ b/src/__tests__/abbreviateForecast.test.ts @@ -28,6 +28,9 @@ describe("forecast truncation", () => { expect(abbreviateForecast("amount 5 - 10 mm", forecastLengthWanted)).toStrictEqual("amount 5-10mm"); expect(abbreviateForecast("local amount 5 - 10 mm", forecastLengthWanted)).toStrictEqual("local amount 5-10mm"); expect(abbreviateForecast("amount 15 - 30 mm", forecastLengthWanted)).toStrictEqual("amount 15-30mm"); + expect(abbreviateForecast("amount 5 - 10 cm", forecastLengthWanted)).toStrictEqual("amount 5-10cm"); + expect(abbreviateForecast("local amount 5 - 10 cm", forecastLengthWanted)).toStrictEqual("local amount 5-10cm"); + expect(abbreviateForecast("amount 15 - 30 cm", forecastLengthWanted)).toStrictEqual("amount 15-30cm"); expect(abbreviateForecast("midnight", forecastLengthWanted)).toStrictEqual("12am"); expect(abbreviateForecast("temperature steady", forecastLengthWanted)).toStrictEqual("temp steady"); expect( diff --git a/src/lib/conditions/forecast.ts b/src/lib/conditions/forecast.ts index 8f8d0509..242774bc 100644 --- a/src/lib/conditions/forecast.ts +++ b/src/lib/conditions/forecast.ts @@ -89,6 +89,10 @@ export function abbreviateForecast( abbreviatedSummary = abbreviatedSummary.replace(/amount (\d+) - (\d+) mm/gi, "amount $1-$2mm"); if (abbreviatedSummary.length <= maxCharacters) return abbreviatedSummary; + // squish up the snowfall amount predicitons + abbreviatedSummary = abbreviatedSummary.replace(/amount (\d+) - (\d+) cm/gi, "amount $1-$2cm"); + if (abbreviatedSummary.length <= maxCharacters) return abbreviatedSummary; + // temperature steady abbreviatedSummary = abbreviatedSummary.replace(/temperature/gi, "temp"); if (abbreviatedSummary.length <= maxCharacters) return abbreviatedSummary;