[IMP] compiler: translatableAttributes can be added/removed

This commit is contained in:
Géry Debongnie
2022-02-03 13:31:30 +01:00
committed by Michaël Mattiello
parent 9424312573
commit 5a7928d3e4
4 changed files with 32 additions and 9 deletions
@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`translation support can set translatable attributes 1`] = `
exports[`translation support can set and remove translatable attributes 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let block1 = createBlock(\`<div tomato=\\"word\\" potato=\\"mot\\" title=\\"word\\">text</div>\`);
let block1 = createBlock(\`<div tomato=\\"word\\" potato=\\"mot\\" title=\\"mot\\" label=\\"word\\">text</div>\`);
return function template(ctx, node, key = \\"\\") {
return block1();
+6 -4
View File
@@ -59,18 +59,20 @@ describe("translation support", () => {
);
});
test("can set translatable attributes", async () => {
test("can set and remove translatable attributes", async () => {
class SomeComponent extends Component {
static template = xml`
<div tomato="word" potato="word" title="word">text</div>
<div tomato="word" potato="word" title="word" label="word">text</div>
`;
}
await mount(SomeComponent, fixture, {
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
translatableAttributes: ["potato"],
translatableAttributes: ["potato", "-label"],
});
expect(fixture.innerHTML).toBe('<div tomato="word" potato="mot" title="word">text</div>');
expect(fixture.innerHTML).toBe(
'<div tomato="word" potato="mot" title="mot" label="word">text</div>'
);
});
test("translation is done on the trimmed text, with extra spaces readded after", async () => {