add {{else}} tests

pull/31/head
Rich-Harris 8 years ago
parent 61c9105c2a
commit 77b600d726

@ -0,0 +1,17 @@
import * as assert from 'assert';
export default {
data: {
foo: true,
bar: false
},
html: '<p>foo</p><!--#if foo--><p>not bar</p><!--#if bar-->',
test ( component, target ) {
component.set({ foo: false });
assert.equal( target.innerHTML, '<p>not foo</p><!--#if foo--><p>not bar</p><!--#if bar-->' );
component.set({ bar: true });
assert.equal( target.innerHTML, '<p>not foo</p><!--#if foo--><p>bar</p><!--#if bar-->' );
component.set({ foo: true });
assert.equal( target.innerHTML, '<p>foo</p><!--#if foo--><p>bar</p><!--#if bar-->' );
}
};

@ -0,0 +1,11 @@
{{#if foo}}
<p>foo</p>
{{else}}
<p>not foo</p>
{{/if}}
{{#if bar}}
<p>bar</p>
{{else}}
<p>not bar</p>
{{/if}}

@ -0,0 +1,5 @@
{{#if foo}}
<p>foo</p>
{{else}}
<p>not foo</p>
{{/if}}

@ -0,0 +1,73 @@
{
"html": {
"start": 0,
"end": 56,
"type": "Fragment",
"children": [
{
"start": 0,
"end": 56,
"type": "IfBlock",
"expression": {
"start": 6,
"end": 9,
"type": "Identifier",
"name": "foo"
},
"children": [
{
"start": 13,
"end": 23,
"type": "Element",
"name": "p",
"attributes": [],
"children": [
{
"start": 16,
"end": 19,
"type": "Text",
"data": "foo"
}
]
}
],
"else": {
"start": 32,
"end": 49,
"type": "ElseBlock",
"children": [
{
"start": 32,
"end": 34,
"type": "Text",
"data": "\n\t"
},
{
"start": 34,
"end": 48,
"type": "Element",
"name": "p",
"attributes": [],
"children": [
{
"start": 37,
"end": 44,
"type": "Text",
"data": "not foo"
}
]
},
{
"start": 48,
"end": 49,
"type": "Text",
"data": "\n"
}
]
}
}
]
},
"css": null,
"js": null
}
Loading…
Cancel
Save