From 9e9bf8c6fabcb17f9bcb04ce1467b00a3e6775d0 Mon Sep 17 00:00:00 2001 From: Gazook89 <58999374+Gazook89@users.noreply.github.com> Date: Tue, 4 Apr 2023 16:32:59 -0500 Subject: [PATCH] Add injection tests --- tests/markdown/mustache-syntax.test.js | 136 +++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/tests/markdown/mustache-syntax.test.js b/tests/markdown/mustache-syntax.test.js index 69670ca2c..f4e2f33d3 100644 --- a/tests/markdown/mustache-syntax.test.js +++ b/tests/markdown/mustache-syntax.test.js @@ -112,6 +112,8 @@ describe('Inline: When using the Inline syntax {{ }}', ()=>{ }); }); +// BLOCK SYNTAX + describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{ it('Renders a div with text only', function() { const source = dedent`{{ @@ -194,6 +196,140 @@ describe(`Block: When using the Block syntax {{tags\\ntext\\n}}`, ()=>{ }); }); +// MUSTACHE INJECTION SYNTAX + +describe('Injection: When an injection tag follows an element', ()=>{ + describe('and that element is an inline-block', ()=>{ + it('Renders a span "text" with no injection', function() { + const source = '{{ text}}{}'; + const rendered = Markdown.render(source); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); + }); + + it('Renders a span "text" with injected Class name', function() { + const source = '{{ text}}{ClassName}'; + const rendered = Markdown.render(source); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); + }); + + it('Renders a span "text" with injected style', function() { + const source = '{{ text}}{color:red}'; + const rendered = Markdown.render(source); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); + }); + + it('Renders a span "text" with two injected styles', function() { + const source = '{{ text}}{color:red,background:blue}'; + const rendered = Markdown.render(source); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text'); + }); + + it('Renders an emphasis element with injected Class name', function() { + const source = '*emphasis*{big}'; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('
emphasis
'); + }); + + it('Renders a code element with injected style', function() { + const source = '`code`{background:gray}'; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('code

text{background:blue}
'); + }); + }); + + describe('and that element is a block', ()=>{ + it('renders a div "text" with no injection', function() { + const source = '{{\ntext\n}}\n{}'; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('text
text
text
text
| Experience Points | Level |
|---|---|
| 0 | 1 |
| 300 | 2 |
{secondInjection}
'); + }); + + it('renders a div nested into another div, the inner with class=innerDiv and the other class=outerDiv', function() { + const source = dedent`{{ + outer text + {{ + inner text + }} + {innerDiv} + }} + {outerDiv}`; + const rendered = Markdown.render(source).trimReturns(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('outer text
inner text