From a9842fb109c22151ac343f3f87861a3431848fa8 Mon Sep 17 00:00:00 2001 From: Jon <66625200+Kyro3400@users.noreply.github.com> Date: Sun, 17 Nov 2024 16:42:57 -0500 Subject: [PATCH] Update domains.test.js --- tests/domains.test.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/domains.test.js b/tests/domains.test.js index 593046c4..8cb68033 100644 --- a/tests/domains.test.js +++ b/tests/domains.test.js @@ -16,10 +16,13 @@ t("Nested subdomains should not exist without a parent subdomain", (t) => { const subdomain = file.replace(".json", ""); if (subdomain.split(".").length > 1) { - const parentSubdomain = subdomain.split(".").pop(); + // Get parent domain by removing the last part (subdomain) from the full subdomain + const parentSubdomain = subdomain.split(".").slice(1).join("."); + + // Ensure the parent subdomain exists t.true( files.includes(`${parentSubdomain}.json`), - `${file}: Parent subdomain does not exist` + `${file}: Parent subdomain ${parentSubdomain}.json does not exist` ); } }); @@ -38,7 +41,9 @@ t("Nested subdomains should not exist if the parent subdomain has NS records", ( const subdomain = file.replace(".json", ""); if (subdomain.split(".").length > 1) { - const parentSubdomain = subdomain.split(".").pop(); + // Get parent domain by removing the last part (subdomain) from the full subdomain + const parentSubdomain = subdomain.split(".").slice(1).join("."); + const parentFilePath = path.join(domainsPath, `${parentSubdomain}.json`); // Check if the parent file exists before attempting to read it