From 387e8ebf645d17225c753920d090072353984768 Mon Sep 17 00:00:00 2001 From: moki Date: Fri, 20 Oct 2023 17:54:38 +0400 Subject: [PATCH] test(xlf/renderer/xlf-md): variable href link --- .../renderer-inline.test.ts.snap | 2 + .../renderer/xlf-md/renderer-inline.test.ts | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/src/xlf/renderer/xlf-md/__snapshots__/renderer-inline.test.ts.snap b/src/xlf/renderer/xlf-md/__snapshots__/renderer-inline.test.ts.snap index c413910a..7acc90ed 100644 --- a/src/xlf/renderer/xlf-md/__snapshots__/renderer-inline.test.ts.snap +++ b/src/xlf/renderer/xlf-md/__snapshots__/renderer-inline.test.ts.snap @@ -21,3 +21,5 @@ exports[`renders xlf to markdown renders samp wrapped in tags 1`] = `"Пре exports[`renders xlf to markdown renders strong wrapped in tags 1`] = `"Предложение номер **один**."`; exports[`renders xlf to markdown renders sup wrapped in tags 1`] = `"Предложение номер ^один^."`; + +exports[`renders xlf to markdown renders variable href link wrapped in and tags 1`] = `"Предложение номер [один]({{one}} \\"one\\")."`; diff --git a/src/xlf/renderer/xlf-md/renderer-inline.test.ts b/src/xlf/renderer/xlf-md/renderer-inline.test.ts index dd0daa56..85691fdd 100644 --- a/src/xlf/renderer/xlf-md/renderer-inline.test.ts +++ b/src/xlf/renderer/xlf-md/renderer-inline.test.ts @@ -361,4 +361,68 @@ describe('renders xlf to markdown', () => { const rendered = renderer.render(tokens); expect(rendered).toMatchSnapshot(); }); + + it('renders variable href link wrapped in and tags', () => { + const renderer = new XLFMDRenderer(); + const tokens: Array = [ + {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(); + }); });