From f6cc7d5f868985ccd20381c7cb03b21d1883b0c2 Mon Sep 17 00:00:00 2001 From: DIBSTER <76603072+DEV-DIBSTER@users.noreply.github.com> Date: Sun, 13 Apr 2025 20:34:25 -0400 Subject: [PATCH] chore: more validation --- tests/json.test.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/json.test.js b/tests/json.test.js index 5e5c50ea..72deb5b8 100644 --- a/tests/json.test.js +++ b/tests/json.test.js @@ -80,6 +80,29 @@ t("All files should have the required fields", (t) => { }); }); +t("All files should have lowercase subdomain/domain and match filename", (t) => { + const files = fs.readdirSync(domainsPath).filter(file => { + const filePath = path.join(domainsPath, file); + return file.endsWith(".json") && fs.lstatSync(filePath).isFile(); + }); + + files.forEach(file => { + const filePath = path.join(domainsPath, file); + const data = fs.readJsonSync(filePath); + + const { subdomain, domain } = data; + + t.truthy(subdomain, `${file}: Missing subdomain field`); + t.truthy(domain, `${file}: Missing domain field`); + + t.is(subdomain, subdomain.toLowerCase(), `${file}: 'subdomain' must be lowercase`); + t.is(domain, domain.toLowerCase(), `${file}: 'domain' must be lowercase`); + + const expectedFileName = `${subdomain}.${domain}.json`; + t.is(file, expectedFileName, `${file}: Filename does not match subdomain and domain`); + }); +}); + t("All files should have valid optional owner fields", (t) => { const files = fs.readdirSync(domainsPath).filter(file => { const filePath = path.join(domainsPath, file);