23 lines
806 B
TypeScript
23 lines
806 B
TypeScript
import { test, expect } from "bun:test";
|
|
import { parse, generate } from "../src/index.ts";
|
|
|
|
test("HTML and component pattern attributes preserve regex quantifiers", () => {
|
|
for (const tag of ["input", "Input"]) {
|
|
for (const pattern of ["[0-9]{6}", "[a-z]{2,8}", "[A-Z]{1,}"]) {
|
|
const code = generate(parse(`page Example { view { <${tag} pattern="${pattern}" /> } }`));
|
|
expect(code).toContain(pattern);
|
|
expect(code).not.toContain("__wrnAttr(6)");
|
|
expect(code).not.toContain("__wrnAttr(2,8)");
|
|
}
|
|
}
|
|
});
|
|
|
|
test("dynamic pattern props still compile as expressions", () => {
|
|
const code = generate(
|
|
parse(
|
|
'component Example { props { pattern: string = "" } view { <input pattern="{pattern}" /> } }',
|
|
),
|
|
);
|
|
expect(code).toContain("__wrnAttr(pattern)");
|
|
});
|