Skip to content

Commit

Permalink
test(xlf/parser): html inline
Browse files Browse the repository at this point in the history
  • Loading branch information
moki committed Nov 21, 2023
1 parent 7ab4d19 commit 923c98c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/xlf/parser/__snapshots__/parser.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,60 @@ Array [
]
`;
exports[`parses translation units with <g> and <x> tags parses inline html wrapped in <x> tags 1`] = `
Array [
Array [
Object {
"data": "target",
"nodeType": "open",
"type": "tag",
},
Object {
"data": "Sentence",
"type": "text",
},
Object {
"data": "x",
"equivText": "<br>",
"nodeType": "self-closing",
"syntax": "html_inline",
"type": "tag",
},
Object {
"data": "with ",
"type": "text",
},
Object {
"data": "x",
"equivText": "<b>",
"nodeType": "self-closing",
"syntax": "html_inline",
"type": "tag",
},
Object {
"data": "html",
"type": "text",
},
Object {
"data": "x",
"equivText": "</b>",
"nodeType": "self-closing",
"syntax": "html_inline",
"type": "tag",
},
Object {
"data": ".",
"type": "text",
},
Object {
"data": "target",
"nodeType": "close",
"type": "tag",
},
],
]
`;
exports[`parses translation units with <g> and <x> tags parses links wrapped in <g> and <x> tags 1`] = `
Array [
Array [
Expand Down
13 changes: 13 additions & 0 deletions src/xlf/parser/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,17 @@ describe('parses translation units with <g> and <x> tags', () => {
expect(translations.length).toStrictEqual(units.length);
expect(translations).toMatchSnapshot();
});

it('parses inline html wrapped in <x> tags', () => {
const units = [
{
id: 1,
target: 'Sentence<x ctype="x-html_inline" equiv-text="&lt;br&gt;" />with <x ctype="x-html_inline" equiv-text="&lt;b&gt;" />html<x ctype="x-html_inline" equiv-text="&lt;/b&gt;" />.',
},
];
const xlf = generateXLF(units);
const translations = parseTranslations({xlf});
expect(translations.length).toStrictEqual(units.length);
expect(translations).toMatchSnapshot();
});
});

0 comments on commit 923c98c

Please sign in to comment.