From 1cbee93c865c8bb8929190e6ac7391654dc1a9c5 Mon Sep 17 00:00:00 2001 From: loloToster Date: Sat, 22 Jan 2022 12:45:00 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20custom=20error=20if=20no=20time?= =?UTF-8?q?=20given=20in=20`getHistory`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 1 + test/errors_test.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index aa4fe72..649679e 100644 --- a/src/index.js +++ b/src/index.js @@ -576,6 +576,7 @@ class OpenWeatherAPI { * }>} */ async getHistory(dt, options = {}) { + if (dt === undefined) throw new Error("Provide time") await this.#uncacheLocation(options.key) dt = Math.round(new Date(dt).getTime() / 1000) options = await this.#parseOptions(options) diff --git a/test/errors_test.js b/test/errors_test.js index c588819..e2c90df 100644 --- a/test/errors_test.js +++ b/test/errors_test.js @@ -126,7 +126,7 @@ describe("Error tests:", function () { try { await weather.getHistory() } catch (err) { - assert(err.message.toLowerCase().includes("no location or time specified")) + assert(err.message.toLowerCase().includes("provide time")) return } assert(false)