From 173c6c3754c0dde439f914a378089f2d8937ad72 Mon Sep 17 00:00:00 2001 From: moki Date: Wed, 15 Nov 2023 18:52:22 +0400 Subject: [PATCH] test(xlf/renderer/xlf-md): liquid filters --- .../renderer-inline.test.ts.snap | 2 ++ .../renderer/xlf-md/renderer-inline.test.ts | 20 +++++++++++++++++++ 2 files changed, 22 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 59ca27c1..a8ab3bff 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 @@ -30,6 +30,8 @@ exports[`renders xlf to markdown renders link wrapped in and tags 1`] = exports[`renders xlf to markdown renders liquid conditions wrapped in tags 1`] = `"Sentence with {% if var == \\"val\\" %} val {% else %} other val {% endif %}."`; +exports[`renders xlf to markdown renders liquid filter wrapped in tags 1`] = `"Sentence with filter {{ users | length }}."`; + exports[`renders xlf to markdown renders liquid function wrapped in tags 1`] = `"Sentence with function {{ user.name.slice(1, 2) }}."`; exports[`renders xlf to markdown renders liquid loop wrapped in tags 1`] = `"Sentence {% for x in xs %} x {% endfor %}."`; diff --git a/src/xlf/renderer/xlf-md/renderer-inline.test.ts b/src/xlf/renderer/xlf-md/renderer-inline.test.ts index ab99a376..39e0f350 100644 --- a/src/xlf/renderer/xlf-md/renderer-inline.test.ts +++ b/src/xlf/renderer/xlf-md/renderer-inline.test.ts @@ -1054,4 +1054,24 @@ describe('renders xlf to markdown', () => { const rendered = renderer.render(tokens); expect(rendered).toMatchSnapshot(); }); + + it('renders liquid filter wrapped in tags', () => { + const renderer = new XLFMDRenderer(); + const tokens: Array = [ + {type: 'tag', data: 'target', nodeType: 'open'}, + {type: 'text', data: 'Sentence with filter '}, + { + type: 'tag', + data: 'x', + nodeType: 'self-closing', + syntax: 'liquid_Filter', + equivText: '{{ users | length }}', + }, + {type: 'text', data: '.'}, + {type: 'tag', data: 'target', nodeType: 'close'}, + ]; + + const rendered = renderer.render(tokens); + expect(rendered).toMatchSnapshot(); + }); });