Files
community-rule/tests/unit/isValidCreateFlowSaveEmail.test.ts
T

26 lines
1.0 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { isValidCreateFlowSaveEmail } from "../../lib/create/isValidCreateFlowSaveEmail";
describe("isValidCreateFlowSaveEmail", () => {
it("rejects empty, whitespace, and non-string values", () => {
expect(isValidCreateFlowSaveEmail("")).toBe(false);
expect(isValidCreateFlowSaveEmail(" ")).toBe(false);
expect(isValidCreateFlowSaveEmail(null)).toBe(false);
expect(isValidCreateFlowSaveEmail(undefined)).toBe(false);
});
it("rejects values the native email control would reject", () => {
expect(isValidCreateFlowSaveEmail("not-an-email")).toBe(false);
expect(isValidCreateFlowSaveEmail("user@example.com ")).toBe(false);
expect(isValidCreateFlowSaveEmail(" user@example.com")).toBe(false);
});
it("accepts a required type=email value", () => {
expect(isValidCreateFlowSaveEmail("user@example.com")).toBe(true);
});
it("rejects a domain with no dot", () => {
expect(isValidCreateFlowSaveEmail("maya@example")).toBe(false);
});
});