Skip to content

Commit

Permalink
feat: Add yield to labels, and fix their tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Radchenko authored and knownasilya committed May 18, 2017
1 parent 8b295cf commit 973e47d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion addon/components/x-toggle-label/template.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{{#if show}}
<label id='{{type}}-label-{{switchId}}' for={{switchId}} class="toggle-text toggle-prefix {{type}}-label"
onclick={{action onClick value}}>
{{label}}
{{#if hasBlock}}
{{yield label}}
{{else}}
{{label}}
{{/if}}
</label>
{{/if}}
14 changes: 13 additions & 1 deletion tests/integration/components/x-toggle-label/component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ moduleForComponent('x-toggle-label', 'Integration | Component | x toggle label',
});

test('it renders', function(assert) {
this.render(hbs`{{x-toggle-label label='test' value=true switchId='test' show=true}}`);
this.set('onClick', () => {});
this.render(hbs`{{x-toggle-label onClick=onClick label='test' value=true switchId='test' show=true}}`);

assert.equal(this.$().text().trim(), 'test');
});

test('it renders in block form', function(assert) {
this.set('onClick', () => {});
this.render(hbs`
{{#x-toggle-label onClick=onClick label='test' value=true switchId='test' show=true as |value|}}
hi {{value}}
{{/x-toggle-label}}
`);

assert.equal(this.$().text().trim(), 'hi test');
});

0 comments on commit 973e47d

Please sign in to comment.