Skip to content

Commit

Permalink
test(xlf/renderer/xlf-md): variable href link
Browse files Browse the repository at this point in the history
  • Loading branch information
moki committed Oct 20, 2023
1 parent e190425 commit 387e8eb
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ exports[`renders xlf to markdown renders samp wrapped in <g> tags 1`] = `"Пре
exports[`renders xlf to markdown renders strong wrapped in <g> tags 1`] = `"Предложение номер **один**."`;
exports[`renders xlf to markdown renders sup wrapped in <g> tags 1`] = `"Предложение номер ^один^."`;
exports[`renders xlf to markdown renders variable href link wrapped in <g> and <x> tags 1`] = `"Предложение номер [один]({{one}} \\"one\\")."`;
64 changes: 64 additions & 0 deletions src/xlf/renderer/xlf-md/renderer-inline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,68 @@ describe('renders xlf to markdown', () => {
const rendered = renderer.render(tokens);
expect(rendered).toMatchSnapshot();
});

it('renders variable href link wrapped in <g> and <x> tags', () => {
const renderer = new XLFMDRenderer();
const tokens: Array<XLFToken> = [
{type: 'tag', data: 'target', nodeType: 'open'},
{type: 'text', data: 'Предложение номер '},
{
type: 'tag',
data: 'g',
nodeType: 'open',
syntax: 'link_text_part',
equivText: '[]',
},
{type: 'text', data: 'один'},
{
type: 'tag',
data: 'g',
nodeType: 'close',
syntax: 'link_text_part',
equivText: '[]',
},
{
type: 'tag',
data: 'g',
nodeType: 'open',
syntax: 'link_attributes_part',
equivText: '()',
},
{
type: 'tag',
data: 'x',
nodeType: 'self-closing',
syntax: 'link_attributes_href',
equivText: '{{one}}',
},
{
type: 'tag',
data: 'g',
nodeType: 'open',
syntax: 'link_attributes_title',
equivText: '""',
},
{type: 'text', data: 'one'},
{
type: 'tag',
data: 'g',
nodeType: 'close',
syntax: 'link_attributes_title',
equivText: '""',
},
{
type: 'tag',
data: 'g',
nodeType: 'close',
syntax: 'link_attributes_part',
equivText: '()',
},
{type: 'text', data: '.'},
{type: 'tag', data: 'target', nodeType: 'close'},
];

const rendered = renderer.render(tokens);
expect(rendered).toMatchSnapshot();
});
});

0 comments on commit 387e8eb

Please sign in to comment.