-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
[QUESTION]: can we update this test to show what ember 2.x tests would do? #215
Comments
Also interested in the idiomatic way to handle this case. how does this piece of code work? hbs`<span>zap zap</span>` Is hbs a function? how can it be called with out parens? |
@josephchappell great question ... come to think of it I never asked how this actually worked myself :) |
Alright, so
So import hbs from "htmlbars-inline-precompile";
import { module, test } from "ember-qunit";
module("my-test");
test("test all the templates", function(assert) {
var template = hbs`
<span>hello world</span>
`;
}); is transformed via import hbs from "htmlbars-inline-precompile";
import { module, test } from "ember-qunit";
module("my-test");
test("test all the templates", function(assert) {
var template = Ember.HTMLBars.template((function () {
return {
isHTMLBars: true,
revision: 'Ember@1.11.1',
blockParams: 0,
cachedFragment: null,
hasRendered: false,
build: function build(dom) {
var el0 = dom.createDocumentFragment();
var el1 = dom.createElement('div');
dom.setAttribute(el1, 'class', 'custom-content');
var el2 = dom.createComment('');
dom.appendChild(el1, el2);
dom.appendChild(el0, el1);
return el0;
},
render: function render(context, env, contextualElement) {
var dom = env.dom;
var hooks = env.hooks,
content = hooks.content;
dom.detectNamespace(contextualElement);
var fragment;
if (env.useFragmentCache && dom.canClone) {
if (this.cachedFragment === null) {
fragment = this.build(dom);
if (this.hasRendered) {
this.cachedFragment = fragment;
} else {
this.hasRendered = true;
}
}
if (this.cachedFragment) {
fragment = dom.cloneNode(this.cachedFragment, true);
}
} else {
fragment = this.build(dom);
}
var morph0 = dom.createMorphAt(dom.childAt(fragment, [0]), 0, 0);
content(env, morph0, context, 'formField.value');
return fragment;
}
};
})())
}); |
@pangratz dude you rawk - hands down the single best reply I've ever seen to a question like this on github. Keep on improving => the ember community is great because of people like you who take the time to help n00bs like me :) |
Thanks for the nice words @toranb! Replies like yours make it worth to take the time and add an explanation. I am very glad that I could help! |
yes thank you very much @pangratz for taking the time to explain that! |
seems like the "issue" here is solved? I'll close this one for now |
I found this line in a test today after looking over some code in ember-qunit
I realized you need a compiler to run this now but ... with a little modification it seems to work like this in ember 2.3. Is it possible to change this so future readers see how easy this is?
https://github.com/rwjblue/ember-qunit/blob/master/tests/module-for-component-test.js#L17
The text was updated successfully, but these errors were encountered: