mirror of https://github.com/sveltejs/svelte
parent
629584d7e9
commit
fce3f342fb
@ -0,0 +1,29 @@
|
|||||||
|
export default {
|
||||||
|
solo: true,
|
||||||
|
|
||||||
|
data: {
|
||||||
|
animals: [ 'alpaca', 'baboon', 'capybara' ]
|
||||||
|
},
|
||||||
|
|
||||||
|
html: `
|
||||||
|
<p>alpaca</p>
|
||||||
|
<p>baboon</p>
|
||||||
|
<p>capybara</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
test ( assert, component, target ) {
|
||||||
|
component.set({ animals: [] });
|
||||||
|
assert.htmlEqual( target.innerHTML, `
|
||||||
|
<p>no animals</p>
|
||||||
|
` );
|
||||||
|
|
||||||
|
// trigger an 'update' of the else block, to ensure that
|
||||||
|
// non-existent update method is not called
|
||||||
|
component.set({ animals: [] });
|
||||||
|
|
||||||
|
component.set({ animals: ['wombat'] });
|
||||||
|
assert.htmlEqual( target.innerHTML, `
|
||||||
|
<p>wombat</p>
|
||||||
|
` );
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
{{#each animals as animal}}
|
||||||
|
<p>{{animal}}</p>
|
||||||
|
{{else}}
|
||||||
|
<p>no animals</p>
|
||||||
|
{{/each}}
|
Loading…
Reference in new issue