You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.0 KiB
84 lines
3.0 KiB
import { describe, expect, test } from "bun:test";
|
|
import { getConfigDefinition, validateConfigValue } from "./registry";
|
|
|
|
describe("comment email config validation", () => {
|
|
test("accepts an empty commentMailFromEmail", () => {
|
|
expect(validateConfigValue("commentMailFromEmail" as never, "")).toBe(true);
|
|
});
|
|
|
|
test("accepts a valid commentMailFromEmail", () => {
|
|
expect(validateConfigValue("commentMailFromEmail" as never, "noreply@example.com")).toBe(true);
|
|
});
|
|
|
|
test("rejects an invalid commentMailFromEmail", () => {
|
|
expect(validateConfigValue("commentMailFromEmail" as never, "invalid-email")).toBe(false);
|
|
});
|
|
|
|
test("validates commentNotifyEnabled as boolean", () => {
|
|
expect(validateConfigValue("commentNotifyEnabled" as never, true)).toBe(true);
|
|
expect(validateConfigValue("commentNotifyEnabled" as never, false)).toBe(true);
|
|
expect(validateConfigValue("commentNotifyEnabled" as never, "true")).toBe(false);
|
|
});
|
|
|
|
test("enforces commentSmtpPort boundaries", () => {
|
|
expect(validateConfigValue("commentSmtpPort" as never, 1)).toBe(true);
|
|
expect(validateConfigValue("commentSmtpPort" as never, 65535)).toBe(true);
|
|
expect(validateConfigValue("commentSmtpPort" as never, 0)).toBe(false);
|
|
expect(validateConfigValue("commentSmtpPort" as never, 65536)).toBe(false);
|
|
expect(validateConfigValue("commentSmtpPort" as never, 465)).toBe(true);
|
|
});
|
|
|
|
test("keeps metadata consistent for new global comment config keys", () => {
|
|
expect(getConfigDefinition("commentEmailNotifyEnabled" as never)).toMatchObject({
|
|
scope: "global",
|
|
valueType: "boolean",
|
|
defaultValue: false,
|
|
userOverridable: false,
|
|
});
|
|
expect(getConfigDefinition("commentMailFromEmail" as never)).toMatchObject({
|
|
scope: "global",
|
|
valueType: "string",
|
|
defaultValue: "",
|
|
userOverridable: false,
|
|
});
|
|
expect(getConfigDefinition("commentSmtpHost" as never)).toMatchObject({
|
|
scope: "global",
|
|
valueType: "string",
|
|
defaultValue: "",
|
|
userOverridable: false,
|
|
});
|
|
expect(getConfigDefinition("commentSmtpPort" as never)).toMatchObject({
|
|
scope: "global",
|
|
valueType: "number",
|
|
defaultValue: 465,
|
|
userOverridable: false,
|
|
});
|
|
expect(getConfigDefinition("commentSmtpSecure" as never)).toMatchObject({
|
|
scope: "global",
|
|
valueType: "boolean",
|
|
defaultValue: true,
|
|
userOverridable: false,
|
|
});
|
|
expect(getConfigDefinition("commentSmtpUser" as never)).toMatchObject({
|
|
scope: "global",
|
|
valueType: "string",
|
|
defaultValue: "",
|
|
userOverridable: false,
|
|
});
|
|
expect(getConfigDefinition("commentSmtpPass" as never)).toMatchObject({
|
|
scope: "global",
|
|
valueType: "string",
|
|
defaultValue: "",
|
|
userOverridable: false,
|
|
});
|
|
});
|
|
|
|
test("keeps metadata consistent for commentNotifyEnabled", () => {
|
|
expect(getConfigDefinition("commentNotifyEnabled" as never)).toMatchObject({
|
|
scope: "both",
|
|
valueType: "boolean",
|
|
defaultValue: true,
|
|
userOverridable: true,
|
|
});
|
|
});
|
|
});
|
|
|