Share base style syntax between rendering and editor validation
Quality / quality (ubuntu-latest) (push) Failing after 1s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-09-05 19:06:09 +05:30
1 parent 16d804e16f
commit 14669bb4f3
4 files changed
+45 -10

No files matched your search

@@ -0,0 +1,13 @@
import { expect, test } from "bun:test";
import { emailStyleValue, validateEmailStyleValue } from "../src/style-values.ts";
test("base style syntax rejects ignored or injected values and accepts supported units", () => {
for (const [key, value] of [["padding","12"],["padding","1px 2px 3px 4px 5px"],["color","#12345"],["fontWeight","heavy"],["fontSize","12px;color:red"],["position","fixed"],["constructor","x"]]) {
expect(emailStyleValue(key!, value)).toBe("");
expect(() => validateEmailStyleValue(key!, value!)).toThrow();
}
for (const [key, value] of [["padding","0 12px"],["margin","1rem 2%"],["color","#1234"],["fontWeight","700"],["fontSize","16px"],["borderRadius","0"],["textAlign","end"]]) {
expect(emailStyleValue(key!, value)).toBe(value!);
expect(() => validateEmailStyleValue(key!, value!)).not.toThrow();
}
});