mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] compiler: translatableAttributes can be added/removed
This commit is contained in:
committed by
Michaël Mattiello
parent
9424312573
commit
5a7928d3e4
@@ -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();
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user