feat: release design system engine, studio and component contracts
This commit is contained in:
1 parent
ff1065fb27
commit
3943b946d6
693 files changed
+175546
-3894
No files matched your search
@@ -2,20 +2,51 @@ 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"]]) {
|
||||
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"]]) {
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
test("RGB functions require correct channel counts, units and bounded components", () => {
|
||||
for (const value of ["rgb(1)", "rgb(1,2,3,4)", "rgba(1,2,3)", "rgb(256,0,0)", "rgb(100%,0,0)", "rgba(1,2,3,1.1)", "rgb(1..2,2,3)", "rgba(0,0,0,101%)"])
|
||||
for (const value of [
|
||||
"rgb(1)",
|
||||
"rgb(1,2,3,4)",
|
||||
"rgba(1,2,3)",
|
||||
"rgb(256,0,0)",
|
||||
"rgb(100%,0,0)",
|
||||
"rgba(1,2,3,1.1)",
|
||||
"rgb(1..2,2,3)",
|
||||
"rgba(0,0,0,101%)",
|
||||
])
|
||||
expect(emailStyleValue("color", value)).toBe("");
|
||||
for (const value of ["rgb(255, 0, 12)", "rgb(100%, 0%, 50%)", "rgba(0,0,0,.5)", "rgba(0,0,0,50%)", "transparent"])
|
||||
for (const value of [
|
||||
"rgb(255, 0, 12)",
|
||||
"rgb(100%, 0%, 50%)",
|
||||
"rgba(0,0,0,.5)",
|
||||
"rgba(0,0,0,50%)",
|
||||
"transparent",
|
||||
])
|
||||
expect(emailStyleValue("backgroundColor", value)).toBe(value);
|
||||
expect(emailStyleValue("padding", "0 4000px")).toBe("0 4000px");
|
||||
expect(emailStyleValue("padding", "0 4001px")).toBe("");
|
||||
|
||||
Reference in new issue
Block a user