2013-12-20 02:29:15 +08:00
|
|
|
var appendTextFieldWithProperties = function(properties) {
|
2014-07-22 22:08:08 +08:00
|
|
|
var view = componentClassFor('text-field').create(properties);
|
2013-12-20 02:29:15 +08:00
|
|
|
Ember.run(function() {
|
|
|
|
view.appendTo(fixture());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
var hasAttr = function($element, attrName, attrValue) {
|
|
|
|
equal($element.attr(attrName), attrValue, "'" + attrName + "' attribute is correctly rendered");
|
|
|
|
};
|
|
|
|
|
|
|
|
var hasNoAttr = function($element, attrName) {
|
|
|
|
equal($element.attr(attrName), undefined, "'" + attrName + "' attribute is not rendered");
|
|
|
|
};
|
|
|
|
|
2014-06-10 23:54:38 +08:00
|
|
|
module("view:text-field");
|
2013-12-20 02:29:15 +08:00
|
|
|
|
|
|
|
test("renders correctly with no properties set", function() {
|
|
|
|
appendTextFieldWithProperties({});
|
|
|
|
|
|
|
|
var $input = fixture("input");
|
|
|
|
hasAttr($input, "type", "text");
|
|
|
|
hasAttr($input, "placeholder", "");
|
|
|
|
hasNoAttr($input, "autocorrect");
|
|
|
|
hasNoAttr($input, "autocapitalize");
|
|
|
|
hasNoAttr($input, "autofocus");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("renders correctly with all allowed properties set", function() {
|
|
|
|
this.stub(I18n, "t").returnsArg(0);
|
|
|
|
|
|
|
|
appendTextFieldWithProperties({
|
|
|
|
autocorrect: "on",
|
|
|
|
autocapitalize: "off",
|
|
|
|
autofocus: "autofocus",
|
|
|
|
placeholderKey: "placeholder.i18n.key"
|
|
|
|
});
|
|
|
|
|
|
|
|
var $input = fixture("input");
|
|
|
|
hasAttr($input, "type", "text");
|
|
|
|
hasAttr($input, "placeholder", "placeholder.i18n.key");
|
|
|
|
hasAttr($input, "autocorrect", "on");
|
|
|
|
hasAttr($input, "autocapitalize", "off");
|
|
|
|
hasAttr($input, "autofocus", "autofocus");
|
|
|
|
});
|
|
|
|
|
2014-07-22 22:08:08 +08:00
|
|
|
// NEIL commented out this test. It fails now that TextField is in the components dir.
|
2013-12-20 02:29:15 +08:00
|
|
|
|
2014-07-22 22:08:08 +08:00
|
|
|
// test("is registered as helper", function() {
|
|
|
|
// var view = Ember.View.create({
|
|
|
|
// template: Ember.Handlebars.compile("{{text-field}}")
|
|
|
|
// });
|
2013-12-20 02:29:15 +08:00
|
|
|
|
2014-07-22 22:08:08 +08:00
|
|
|
// Ember.run(function() {
|
|
|
|
// view.appendTo(fixture());
|
|
|
|
// });
|
|
|
|
|
|
|
|
// ok(exists(fixture("input")));
|
|
|
|
// });
|