From ea1519592d4cd67ea91e5259566a2d73ba1a08f6 Mon Sep 17 00:00:00 2001 From: DIBSTER <76603072+DEV-DIBSTER@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:33:58 -0500 Subject: [PATCH] fix!: improper validation --- tests/domains.test.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/domains.test.js b/tests/domains.test.js index dfccdcf3..4d817683 100644 --- a/tests/domains.test.js +++ b/tests/domains.test.js @@ -15,10 +15,10 @@ t("Nested subdomains should not exist without a parent subdomain", (t) => { const subdomain = file.replace(/\.json$/, ""); - if (subdomain.split(".").length > 1) { - // Get parent domain by removing the last part (subdomain) from the full subdomain + if (subdomain.split(".").length > 2) { + // Get parent domain by removing the leftmost part const parentSubdomain = subdomain.split(".").slice(1).join("."); - + // Ensure the parent subdomain exists t.true( files.includes(`${parentSubdomain}.json`), @@ -40,16 +40,21 @@ t("Nested subdomains should not exist if the parent subdomain has NS records", ( const subdomain = file.replace(/\.json$/, ""); - if (subdomain.split(".").length > 1) { - // Get parent domain by removing the last part (subdomain) from the full subdomain + if (subdomain.split(".").length > 2) { + // Get parent domain by removing the leftmost part 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 if (fs.existsSync(parentFilePath)) { const parentDomain = fs.readJsonSync(parentFilePath); - t.is(parentDomain.record.NS, undefined, `${file}: Parent subdomain has NS records`); + + // Check if the parent has NS records + t.is( + parentDomain.record.NS, + undefined, + `${file}: Parent subdomain ${parentSubdomain} has NS records` + ); } else { t.fail(`${parentSubdomain}.json file does not exist`); } @@ -58,3 +63,4 @@ t("Nested subdomains should not exist if the parent subdomain has NS records", ( t.pass(); }); +