diff --git a/ren/str.test.ts b/ren/str.test.ts index 2d0617e..8fc7613 100644 --- a/ren/str.test.ts +++ b/ren/str.test.ts @@ -144,3 +144,43 @@ Deno.test({ assertEquals(res, "
"); }, }); + +Deno.test({ + name: "should change attr key", + fn: () => { + const layout = E("a", { + target: "_blank", + href: "/hello/world", + rel: "nofollow noopener", + }, "hello world"); + + const ren = new StrRenderer({ + onVisitAttr: ([key, val]) => [`data-${key}`, val], + }); + const res = ren.render(layout); + + assertEquals( + res, + 'hello world', + ); + }, +}); + +Deno.test({ + name: "should change attr value", + fn: () => { + const layout = E("a", { + href: "/hello/world", + }, "hello world"); + + const ren = new StrRenderer({ + onVisitAttr: ([key, val]) => [key, "/eng" + val], + }); + const res = ren.render(layout); + + assertEquals( + res, + 'hello world', + ); + }, +});