Skip to content

Commit ff40dff

Browse files
test(weather): add regression test for weathergov forecast day skipping
1 parent 2e19b71 commit ff40dff

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

‎tests/unit/modules/default/weather/providers/weathergov_spec.js‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,36 @@ describe("WeatherGovProvider", () => {
241241
expect(day).toHaveProperty("weatherType");
242242
expect(day).toHaveProperty("precipitationProbability");
243243
});
244+
245+
it("should not skip the first day of forecast data", async () => {
246+
const provider = new WeatherGovProvider({
247+
lat: 40.71,
248+
lon: -74.0,
249+
type: "forecast"
250+
});
251+
252+
const dataPromise = new Promise((resolve) => {
253+
provider.setCallbacks(resolve, vi.fn());
254+
});
255+
256+
server.use(
257+
http.get(WEATHERGOV_FORECAST_URL, () => {
258+
return HttpResponse.json(forecastData);
259+
})
260+
);
261+
262+
await provider.initialize();
263+
provider.start();
264+
265+
const result = await dataPromise;
266+
267+
// Mock data starts on 2026-02-06 ("This Afternoon").
268+
// Before the fix, slice(1) dropped today, so result[0] would have been 2026-02-07.
269+
const firstDate = result[0].date;
270+
expect(firstDate.getFullYear()).toBe(2026);
271+
expect(firstDate.getMonth()).toBe(1); // February (0-indexed)
272+
expect(firstDate.getDate()).toBe(6);
273+
});
244274
});
245275

246276
describe("Hourly Parsing", () => {

0 commit comments

Comments
 (0)