From efe8cd0060bbb0c77e6e8002d9e6c4442753a150 Mon Sep 17 00:00:00 2001 From: Matt Hadden Date: Wed, 8 Nov 2023 18:14:37 -0500 Subject: [PATCH] refactor(forecast): abbr pellets --- src/__tests__/abbreviateForecast.test.ts | 3 +++ src/lib/conditions/forecast.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/__tests__/abbreviateForecast.test.ts b/src/__tests__/abbreviateForecast.test.ts index 0d89cc83..5f20e75f 100644 --- a/src/__tests__/abbreviateForecast.test.ts +++ b/src/__tests__/abbreviateForecast.test.ts @@ -145,6 +145,9 @@ describe("Forecast Truncation", () => { "100% chnc of flrys" ); expect(abbreviateForecast("5 percent chance of flurries", forecastLengthWanted)).toStrictEqual("5% chnc of flrys"); + expect(abbreviateForecast("rain mixed with ice pellets", forecastLengthWanted)).toStrictEqual( + "rain mixed w/ ice plts" + ); }); test("Compass directions", () => { diff --git a/src/lib/conditions/forecast.ts b/src/lib/conditions/forecast.ts index 568311fd..f6437816 100644 --- a/src/lib/conditions/forecast.ts +++ b/src/lib/conditions/forecast.ts @@ -158,7 +158,8 @@ const abbreviateWinterConditions = (forecast: string) => .replace(/blowing snow/gi, "blwg snow") .replace(/flurries/gi, "flrys") .replace(/freezing drizzle/gi, "frzg drzl") - .replace(/freezing rain/gi, "frzg rain"); + .replace(/freezing rain/gi, "frzg rain") + .replace(/pellets/gi, "plts"); const finalAbbreviationAttempt = (forecast: string) => forecast.replace(/kmh/gi, "");