From 492bcd71c331ada16b59499bd3bb171c3e2a928a Mon Sep 17 00:00:00 2001 From: Zuri Klaschka Date: Tue, 29 Oct 2024 03:34:19 +0100 Subject: [PATCH] test: :white_check_mark: Add "No value" tests --- mod_test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mod_test.ts b/mod_test.ts index 15a8c88..477beb3 100644 --- a/mod_test.ts +++ b/mod_test.ts @@ -232,4 +232,22 @@ Deno.test("initVariable", async (t) => { "Expected the default value to be used in process.env", ); }); + + await t.step("No Value", async (t) => { + prepare(); + await assertRejects( + () => initVariable(ENV_VAR, REQUIRED_PASSING), + ConfigParseError, + undefined, + "Expected a ConfigParseError when no value is set", + ); + + prepare(); + await initVariable(ENV_VAR, OPTIONAL_PASSING); + await assertEquals( + Deno.env.get(ENV_VAR), + undefined, + "Expected the value to be undefined", + ); + }); });