mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-09-02 10:20:00 +00:00
improve tests
This commit is contained in:
+12
-6
@@ -2,21 +2,27 @@ const t = require("ava");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
|
||||
const requiredRecordsToProxy = ["A", "AAAA", "CNAME"];
|
||||
const requiredRecordsToProxy = new Set(["A", "AAAA", "CNAME"]);
|
||||
// URL records are not listed here because they are proxied by default, so they don't need the proxied flag
|
||||
|
||||
function validateProxiedRecords(t, data, file) {
|
||||
if (data.proxied) {
|
||||
const hasProxiedRecord = Object.keys(data.record).some((key) => requiredRecordsToProxy.includes(key));
|
||||
// Convert the Set to an array for message display
|
||||
const recordTypes = Array.from(requiredRecordsToProxy).join(", ");
|
||||
|
||||
t.true(hasProxiedRecord, `${file}: Proxied is true but there are no records that can be proxied`);
|
||||
if (data.proxied) {
|
||||
const hasProxiedRecord = Object.keys(data.record).some((key) => requiredRecordsToProxy.has(key));
|
||||
|
||||
t.true(
|
||||
hasProxiedRecord,
|
||||
`${file}: Proxied is true but there are no records that can be proxied (${recordTypes} expected)`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const domainsPath = path.resolve("domains");
|
||||
const files = fs.readdirSync(domainsPath);
|
||||
const files = fs.readdirSync(domainsPath).filter((file) => file.endsWith(".json"));
|
||||
|
||||
t("Domains with proxy enabled should have have at least one record that can be proxied", (t) => {
|
||||
t("Domains with proxy enabled should have at least one record that can be proxied", (t) => {
|
||||
files.forEach((file) => {
|
||||
const domain = fs.readJsonSync(path.join(domainsPath, file));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user