Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating a helper also generates a test #1503

Merged
merged 1 commit into from
Jul 27, 2014

Conversation

kimroen
Copy link
Contributor

@kimroen kimroen commented Jul 27, 2014

This will generate a test in addition to the helper when you run ember generate helper my-helper.

The helper itself was also restructured a bit to accommodate for this, as per a suggestion by @rwjblue (thanks!).

@jakecraige
Copy link
Member

Why was how it exports changed? Couldn't you just

import myHelper form app/helpers/my-helper';

/cc @rwjblue

@rwjblue
Copy link
Member

rwjblue commented Jul 27, 2014

Basically, exporting the function (as a named export) makes testing the function itself MUCH easier. You can just import the regular JS function, and test it's expect inputs and outputs by invoking the function directly. This allows you to test your function without 'testing the framework'.

The default export of the helper is unchanged.

@rwjblue
Copy link
Member

rwjblue commented Jul 27, 2014

@jakecraige - I realize I didn't answer your question directly. If you import the default export (as you suggested) you are importing the result of Ember.Handlebars.makeBoundHelper not the function you created.

@jakecraige
Copy link
Member

@rwjblue Ah! That makes sense. Cool

rwjblue added a commit that referenced this pull request Jul 27, 2014
Generating a helper also generates a test
@rwjblue rwjblue merged commit 6b98fee into ember-cli:master Jul 27, 2014
@kimroen kimroen deleted the generate-helper-test branch July 28, 2014 09:18
@kimroen
Copy link
Contributor Author

kimroen commented Jul 28, 2014

I was thinking of adding some more explanatory example tests, but the problem is that anything more than checking for existence will make the dummy test fail once you implement something in the helper.

Maybe comments in the helper itself could be useful?

Thoughts on this?

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

Successfully merging this pull request may close these issues.

None yet

3 participants