2015-04-08 14:17:21 -04:00
|
|
|
import Presence from 'discourse/mixins/presence';
|
|
|
|
|
2013-10-15 12:00:10 -04:00
|
|
|
var oldHelpers;
|
|
|
|
|
|
|
|
module("Discourse.View", {
|
|
|
|
setup: function() {
|
|
|
|
oldHelpers = Ember.Handlebars.helpers;
|
|
|
|
},
|
|
|
|
|
|
|
|
teardown: function() {
|
|
|
|
Ember.Handlebars.helpers = oldHelpers;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-04-08 14:17:21 -04:00
|
|
|
test("mixes in Presence", function() {
|
|
|
|
ok(Presence.detect(Discourse.View.create()));
|
2013-10-15 12:00:10 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test("registerHelper: enables embedding a child view in a parent view via dedicated, named helper instead of generic 'view' helper", function() {
|
|
|
|
Discourse.View.registerHelper("childViewHelper", Ember.View.extend({
|
|
|
|
template: Ember.Handlebars.compile('{{view.text}}')
|
|
|
|
}));
|
|
|
|
|
|
|
|
var parentView = Ember.View.extend({
|
|
|
|
template: Ember.Handlebars.compile('{{childViewHelper id="child" text="foo"}}')
|
|
|
|
}).create();
|
|
|
|
|
|
|
|
Ember.run(function() {
|
|
|
|
parentView.appendTo("#qunit-fixture");
|
|
|
|
});
|
|
|
|
|
|
|
|
equal(parentView.$("#child").length, 1, "child view registered as helper is appended to the parent view");
|
|
|
|
equal(parentView.$("#child").text(), "foo", "child view registered as helper gets parameters provided during helper invocation in parent's template");
|
|
|
|
});
|