From 041a7952512ef6a57aeff134b9b9a5564c578f3e Mon Sep 17 00:00:00 2001 From: DIBSTER <76603072+DEV-DIBSTER@users.noreply.github.com> Date: Thu, 5 Dec 2024 17:52:08 -0500 Subject: [PATCH] chore: testing --- tests/domains.test.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/domains.test.js b/tests/domains.test.js index 0fa7a47f..9d592f4f 100644 --- a/tests/domains.test.js +++ b/tests/domains.test.js @@ -14,6 +14,8 @@ function isRootDomain(domain) { } t("Nested subdomains should not exist without a parent subdomain", (t) => { + const issues = []; + files.forEach((file) => { // Skip directories and process only .json files const filePath = path.join(domainsPath, file); @@ -26,24 +28,26 @@ t("Nested subdomains should not exist without a parent subdomain", (t) => { if (subdomain.split(".").length > 2) { // Get parent domain by removing the leftmost part const parentSubdomain = subdomain.split(".").slice(1).join("."); - + // Skip check if the parent subdomain is a root domain if (isRootDomain(parentSubdomain)) { return; } - // Ensure the parent subdomain exists - t.true( - files.includes(`${parentSubdomain}.json`), - `${file}: Parent subdomain ${parentSubdomain}.json does not exist` - ); + // Check if the parent subdomain exists + if (!files.includes(`${parentSubdomain}.json`)) { + issues.push(`${file}: Parent subdomain ${parentSubdomain}.json does not exist`); + } } }); - t.pass(); + // Report all issues at once + t.deepEqual(issues, [], `Found issues:\n${issues.join("\n")}`); }); t("Nested subdomains should not exist if the parent subdomain has NS records", (t) => { + const issues = []; + files.forEach((file) => { // Skip directories and process only .json files const filePath = path.join(domainsPath, file); @@ -68,16 +72,15 @@ t("Nested subdomains should not exist if the parent subdomain has NS records", ( const parentDomain = fs.readJsonSync(parentFilePath); // Check if the parent has NS records - t.is( - parentDomain.record.NS, - undefined, - `${file}: Parent subdomain ${parentSubdomain} has NS records` - ); + if (parentDomain.record.NS !== undefined) { + issues.push(`${file}: Parent subdomain ${parentSubdomain} has NS records`); + } } else { - t.fail(`${parentSubdomain}.json file does not exist`); + issues.push(`${file}: Parent subdomain ${parentSubdomain}.json file does not exist`); } } }); - t.pass(); + // Report all issues at once + t.deepEqual(issues, [], `Found issues:\n${issues.join("\n")}`); });