Skip to content

Commit

Permalink
fixup: add more tests
Browse files Browse the repository at this point in the history
add else variant tests

fixup
  • Loading branch information
nknapp committed Apr 10, 2020
1 parent 9468f00 commit 30a5e54
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/markup/handlebars/block-parameters-as.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<span class="hljs-template-tag">{{#<span class="hljs-name"><span class="hljs-builtin-name">each</span></span> filter <span class="hljs-keyword">as</span> | value index|}}</span><span class="xml"> </span><span class="hljs-template-tag">{{/<span class="hljs-name"><span class="hljs-builtin-name">each</span></span>}}</span><span class="xml">

</span><span class="hljs-template-tag">{{#<span class="hljs-name"><span class="hljs-builtin-name">with</span></span> as <span class="hljs-keyword">as</span> | as |}}</span><span class="xml"> </span><span class="hljs-template-tag">{{/<span class="hljs-name"><span class="hljs-builtin-name">with</span></span>}}</span><span class="xml">
</span>
3 changes: 3 additions & 0 deletions test/markup/handlebars/block-parameters-as.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#each filter as | value index|}} {{/each}}

{{#with as as | as |}} {{/with}}
6 changes: 6 additions & 0 deletions test/markup/handlebars/combinations-with-text.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<span class="xml">some text

</span><span class="hljs-template-tag">{{#<span class="hljs-name">custom</span> (<span class="hljs-name">nested</span> (<span class="hljs-name">helper</span> <span class="hljs-string">'a{{bc'</span> <span class="hljs-number">1</span>)) <span class="hljs-attr">key</span>=value <span class="hljs-keyword">as</span> | blockParam |}}</span><span class="xml"> some </span><span class="hljs-template-variable">{{<span class="hljs-name">blockParam</span>}}</span><span class="xml"> text </span><span class="hljs-template-tag">{{/<span class="hljs-name">custom</span>}}</span><span class="xml">

some text
</span>
5 changes: 5 additions & 0 deletions test/markup/handlebars/combinations-with-text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
some text

{{#custom (nested (helper 'a{{bc' 1)) key=value as | blockParam |}} some {{blockParam}} text {{/custom}}

some text
11 changes: 11 additions & 0 deletions test/markup/handlebars/else-variants.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<span class="hljs-template-tag">{{#<span class="hljs-name">helper</span>}}</span><span class="hljs-keyword">{{else}}</span><span class="xml">else-block</span><span class="hljs-template-tag">{{/<span class="hljs-name">helper</span>}}</span><span class="xml">

</span><span class="hljs-template-tag">{{#<span class="hljs-name">helper</span>}}</span><span class="xml">block</span><span class="hljs-keyword">{{else}}</span><span class="xml">else-block</span><span class="hljs-template-tag">{{/<span class="hljs-name">helper</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">[else]</span>}}</span><span class="xml"> in brackets is a helper, not a keyword

</span><span class="hljs-template-tag">{{#<span class="hljs-name">else</span>}}</span><span class="xml"> as block helper name is not a keyword </span><span class="hljs-template-tag">{{/<span class="hljs-name">else</span>}}</span><span class="xml">

\{{else}} is not a keyword if escaped

</span>
10 changes: 10 additions & 0 deletions test/markup/handlebars/else-variants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{#helper}}{{else}}else-block{{/helper}}

{{#helper}}block{{else}}else-block{{/helper}}

{{[else]}} in brackets is a helper, not a keyword

{{#else}} as block helper name is not a keyword {{/else}}

\{{else}} is not a keyword if escaped

12 changes: 12 additions & 0 deletions test/markup/handlebars/hashes.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<span class="hljs-template-variable">{{<span class="hljs-name">helper</span> <span class="hljs-attr">key</span>=value}}</span><span class="xml">

</span><span class="hljs-template-variable">{{{<span class="hljs-name">helper</span> <span class="hljs-attr">key</span>=value}}}</span><span class="xml">

</span><span class="hljs-template-variable">{{&gt;<span class="hljs-name"><span class="hljs-builtin-name">partial</span></span> <span class="hljs-attr">key</span>=value}}</span><span class="xml">

</span><span class="hljs-template-tag">{{#<span class="hljs-name">helper</span> <span class="hljs-attr">key</span>=value}}</span><span class="xml"> </span><span class="hljs-template-tag">{{/<span class="hljs-name">helper</span>}}</span><span class="xml">

</span><span class="hljs-template-tag">{{{{#<span class="hljs-name">helper</span> <span class="hljs-attr">key</span>=value}}}}</span><span class="xml"> </span><span class="hljs-template-tag">{{{{/<span class="hljs-name">helper</span>}}}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> (<span class="hljs-name">subExpression</span> <span class="hljs-attr">key</span>=value)}}</span><span class="xml">
</span>
11 changes: 11 additions & 0 deletions test/markup/handlebars/hashes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{helper key=value}}

{{{helper key=value}}}

{{>partial key=value}}

{{#helper key=value}} {{/helper}}

{{{{#helper key=value}}}} {{{{/helper}}}}

{{helper (subExpression key=value)}}
14 changes: 14 additions & 0 deletions test/markup/handlebars/literals-in-different-places.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<span class="hljs-template-variable">{{<span class="hljs-name">helper</span> <span class="hljs-literal">true</span> <span class="hljs-literal">false</span> <span class="hljs-attr">a</span>=<span class="hljs-literal">true</span> <span class="hljs-attr">b</span>=<span class="hljs-literal">false</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{{<span class="hljs-name">helper</span> <span class="hljs-literal">true</span> <span class="hljs-literal">false</span>}}}</span><span class="xml">

</span><span class="hljs-template-tag">{{#<span class="hljs-name">helper</span> <span class="hljs-literal">true</span> <span class="hljs-literal">false</span>}}</span><span class="xml"> </span><span class="hljs-template-tag">{{/<span class="hljs-name">helper</span>}}</span><span class="xml">

</span><span class="hljs-template-tag">{{{{#<span class="hljs-name">helper</span> <span class="hljs-literal">true</span> <span class="hljs-literal">false</span>}}}}</span><span class="xml"> </span><span class="hljs-template-tag">{{{{/<span class="hljs-name">helper</span>}}}}</span><span class="xml">

</span><span class="hljs-template-variable">{{&gt;<span class="hljs-name"><span class="hljs-builtin-name">partial</span></span> <span class="hljs-literal">true</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> (<span class="hljs-name">helper</span> <span class="hljs-literal">true</span> <span class="hljs-literal">false</span>)}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> <span class="hljs-attr">a</span>=<span class="hljs-literal">true</span> <span class="hljs-attr">b</span>=<span class="hljs-literal">false</span>}}</span><span class="xml">
</span>
13 changes: 13 additions & 0 deletions test/markup/handlebars/literals-in-different-places.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{helper true false a=true b=false}}

{{{helper true false}}}

{{#helper true false}} {{/helper}}

{{{{#helper true false}}}} {{{{/helper}}}}

{{>partial true}}

{{helper (helper true false)}}

{{helper a=true b=false}}
14 changes: 14 additions & 0 deletions test/markup/handlebars/literals.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<span class="hljs-template-variable">{{<span class="hljs-name">helper</span> <span class="hljs-literal">true</span> <span class="hljs-literal">false</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> <span class="hljs-number">1234</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> <span class="hljs-literal">null</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> <span class="hljs-literal">undefined</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> <span class="hljs-string">'string'</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> <span class="hljs-string">"string"</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> [not a string literal but a variable]}}</span><span class="xml">
</span>
13 changes: 13 additions & 0 deletions test/markup/handlebars/literals.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{helper true false}}

{{helper 1234}}

{{helper null}}

{{helper undefined}}

{{helper 'string'}}

{{helper "string"}}

{{helper [not a string literal but a variable]}}
10 changes: 10 additions & 0 deletions test/markup/handlebars/path-expressions.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<span class="hljs-template-variable">{{<span class="hljs-name">path.expression</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{{<span class="hljs-name">path.expression</span>}}}</span><span class="xml">

</span><span class="hljs-template-tag">{{#<span class="hljs-name">path.expression</span>}}</span><span class="xml"> </span><span class="hljs-template-tag">{{/<span class="hljs-name">path.expression</span>}}</span><span class="xml">

</span><span class="hljs-template-tag">{{{{#<span class="hljs-name">path.expression</span>}}}}</span><span class="xml"> </span><span class="hljs-template-tag">{{{{/<span class="hljs-name">path.expression</span>}}}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">with.in.a.path.expression</span>}}</span><span class="xml"> is not a built-in
</span>
9 changes: 9 additions & 0 deletions test/markup/handlebars/path-expressions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{path.expression}}

{{{path.expression}}}

{{#path.expression}} {{/path.expression}}

{{{{#path.expression}}}} {{{{/path.expression}}}}

{{with.in.a.path.expression}} is not a built-in
12 changes: 12 additions & 0 deletions test/markup/handlebars/sub-expressions.expect.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
<span class="hljs-template-variable">{{<span class="hljs-name">helper</span> (<span class="hljs-name">subExpression</span> <span class="hljs-number">1</span> <span class="hljs-number">2</span>)}}</span><span class="xml">

</span><span class="hljs-template-variable">{{{<span class="hljs-name">helper</span> (<span class="hljs-name">subExpression</span> <span class="hljs-number">1</span> <span class="hljs-number">2</span>)}}}</span><span class="xml">

</span><span class="hljs-template-tag">{{{{#<span class="hljs-name">helper</span> (<span class="hljs-name">subExpression</span> <span class="hljs-number">1</span> <span class="hljs-number">2</span>)}}}}</span><span class="xml"> </span><span class="hljs-template-tag">{{{{/<span class="hljs-name">helper</span>}}}}</span><span class="xml">

</span><span class="hljs-template-tag">{{#<span class="hljs-name">helper</span> (<span class="hljs-name">subExpression</span> <span class="hljs-number">1</span> <span class="hljs-number">2</span>)}}</span><span class="xml"> </span><span class="hljs-template-tag">{{/<span class="hljs-name">helper</span>}}</span><span class="xml">

</span><span class="hljs-template-variable">{{&gt;<span class="hljs-name"><span class="hljs-builtin-name">partial</span></span> (<span class="hljs-name">subExpression</span> <span class="hljs-number">1</span> <span class="hljs-number">2</span>)}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> <span class="hljs-attr">key</span>=(<span class="hljs-name">subExpression</span> <span class="hljs-number">1</span> <span class="hljs-number">2</span>)}}</span><span class="xml">

</span><span class="hljs-template-variable">{{<span class="hljs-name">helper</span> (<span class="hljs-name">subExpression</span> (<span class="hljs-name">canBeNested</span> <span class="hljs-number">1</span> <span class="hljs-number">2</span>) anotherParam)}}</span><span class="xml">
</span>
12 changes: 12 additions & 0 deletions test/markup/handlebars/sub-expressions.txt
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
{{helper (subExpression 1 2)}}

{{{helper (subExpression 1 2)}}}

{{{{#helper (subExpression 1 2)}}}} {{{{/helper}}}}

{{#helper (subExpression 1 2)}} {{/helper}}

{{>partial (subExpression 1 2)}}

{{helper key=(subExpression 1 2)}}

{{helper (subExpression (canBeNested 1 2) anotherParam)}}

0 comments on commit 30a5e54

Please sign in to comment.