Skip to content

Commit

Permalink
[glimmer2] fix unbound helper test
Browse files Browse the repository at this point in the history
Before, the test rendered the following:

```handlebars
<div data-foo="{{if cond1 \"T1\" \"F1\"}}"></div>
<div data-foo="{{if cond2 \"T2\" \"F2\"}}"></div>
```

The test was only asserting against the value of the `data-foo` of the
first div, causing it fo fail because it was missing the value of the
`data-foo` in the second div.

This is because the test was using `wrappedTemplateFor`, which
is a convenience method which only expects *one* template to be
rendered at a time.

Instead, we use `wrapperFor` and two `templateFor` calls to instead
create only *one* div and assert against it. What's rendered in the test
now looks like:

```handlebars
<div data-foo="{{if cond1 \"T1\" \"F1\"}}{{if cond2 \"T2\" \"F2\"}}"></div>
```

refs emberjs#13644
  • Loading branch information
Stanley Stuart committed Jun 19, 2016
1 parent 81102a1 commit ab927c4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/ember-glimmer/tests/utils/shared-conditional-tests.js
Expand Up @@ -494,12 +494,11 @@ export class TogglingHelperConditionalsTest extends TogglingConditionalsTest {
this.render(wrappedTemplate, context);
}

['@htmlbars it does not update when the unbound helper is used']() {
let template = `${
this.wrappedTemplateFor({ cond: '(unbound cond1)', truthy: '"T1"', falsy: '"F1"' })
}${
this.wrappedTemplateFor({ cond: '(unbound cond2)', truthy: '"T2"', falsy: '"F2"' })
}`;
['@test it does not update when the unbound helper is used']() {
let template = this.wrapperFor([
this.templateFor({ cond: '(unbound cond1)', truthy: '"T1"', falsy: '"F1"' }),
this.templateFor({ cond: '(unbound cond2)', truthy: '"T2"', falsy: '"F2"' })
]);

this.render(template, { cond1: this.truthyValue, cond2: this.falsyValue });

Expand Down

0 comments on commit ab927c4

Please sign in to comment.