Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Testing component blocks #158

Closed
wants to merge 1 commit into from
Closed

Conversation

knownasilya
Copy link
Contributor

Often you might define a component which works in block form:

```app/templates/components/my-component.hbs
{{#if template}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We intend to add hasBlock? helper for this, I am unsure that we should suggest this (though checking template will likely always work).

@trek
Copy link
Member

trek commented Jun 12, 2015

Going to close from lack of reply/activity. Feel free to re-open if we can address @rwjblue's question.

@trek trek closed this Jun 12, 2015
@knownasilya
Copy link
Contributor Author

What was the question? lol. Looks like we are waiting on hasBlock? to be implemented? Seems silly to wait on that and not have any documentation in the mean time. We can always update the docs once that has landed.

@rwjblue
Copy link
Member

rwjblue commented Jun 12, 2015

Accessing this.get('template') triggers a deprecation in 1.13, and hasBlock is enabled in 1.13.

@rwjblue
Copy link
Member

rwjblue commented Jun 12, 2015

Also, setting template does nothing in 1.13.

@knownasilya
Copy link
Contributor Author

@rwjblue so just replace template with hasBlock?

@knownasilya
Copy link
Contributor Author

What's the alternative to setting template?

@rwjblue
Copy link
Member

rwjblue commented Jun 12, 2015

so just replace template with hasBlock?

Yes, without the question mark:

{{#if hasBlock}}
  Stuff
{{/if}}

@knownasilya
Copy link
Contributor Author

@rwjblue what about setting the template? What's the new API for that?

@rwjblue
Copy link
Member

rwjblue commented Jun 12, 2015

There isn't one. The template for a component is supplied by the block provided by the calling location.

Please explain the intent of changing the template of a component, maybe I have a better answer/explaination...

@knownasilya
Copy link
Contributor Author

For testing integration between different components, e.g.

{{#video-player as |playing|}}
  {{ad-overlay ad=myAd playing=playing}}
{{/video-player}}

Or even static data, since you want to test if your component is behaving correctly when in block mode.

@rwjblue
Copy link
Member

rwjblue commented Jun 12, 2015

For testing, you should be using the newer style component integration tests. We need more documentation for it though.

Added in emberjs/ember-test-helpers#38, you can do something like this example from liquid-fire.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants