From 118390410760a7bc310eea3910f0a4d07cefc2f7 Mon Sep 17 00:00:00 2001 From: Jon <66625200+Kyro3400@users.noreply.github.com> Date: Sun, 17 Nov 2024 16:29:50 -0500 Subject: [PATCH] Update records.test.js --- tests/records.test.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/records.test.js b/tests/records.test.js index 515a06f0..8bc71001 100644 --- a/tests/records.test.js +++ b/tests/records.test.js @@ -86,9 +86,22 @@ function isPublicIPv6(ip) { ); } +const files = fs.readdirSync(domainsPath); + +function isDirectory(filePath) { + return fs.lstatSync(filePath).isDirectory(); +} + t("All files should have valid record types", (t) => { files.forEach((file) => { - const data = fs.readJsonSync(path.join(domainsPath, file)); + const filePath = path.join(domainsPath, file); + + // Skip directories + if (isDirectory(filePath)) { + return; + } + + const data = fs.readJsonSync(filePath); const recordKeys = Object.keys(data.record); recordKeys.forEach((key) => { @@ -97,7 +110,7 @@ t("All files should have valid record types", (t) => { // CNAME records cannot be combined with any other record type if (recordKeys.includes("CNAME")) { - t.is(recordKeys.length, Number(1), `${file}: CNAME records cannot be combined with other records`); + t.is(recordKeys.length, 1, `${file}: CNAME records cannot be combined with other records`); } // NS records cannot be combined with any other record type, except for DS records