test: add a check for form fields random to not be required

This commit is contained in:
Nicolas Meienberger 2023-07-07 08:10:15 +02:00
parent defd7a53fc
commit f2f172bd3d

View File

@ -1,6 +1,11 @@
import fs from "fs"; import fs from "fs";
import jsyaml from "js-yaml"; import jsyaml from "js-yaml";
type FormField = {
type: "random";
required: boolean;
};
interface AppConfig { interface AppConfig {
id: string; id: string;
port: number; port: number;
@ -16,6 +21,7 @@ interface AppConfig {
author: string; author: string;
source: string; source: string;
available: boolean; available: boolean;
form_fields?: FormField[];
} }
const networkExceptions = [ const networkExceptions = [
@ -245,4 +251,20 @@ describe("App configs", () => {
}); });
}); });
}); });
describe("All form fields with type random should not be marked as required", () => {
const configs = getAppConfigs();
configs.forEach((config) => {
const formFields = config.form_fields;
if (formFields) {
formFields.forEach((field) => {
if (field.type === "random") {
test(config.id, () => {
expect(Boolean(field.required)).toBe(false);
});
}
});
}
});
});
}); });