[imp] added some tests, debugged some bugs
bzr revid: nicolas.vanhoren@openerp.com-20120224135027-axsjx7x0ajlzvolh
This commit is contained in:
parent
a2b9874378
commit
8a8da7973a
|
@ -340,8 +340,6 @@ niv = (function() {
|
|||
* for new components this argument should not be provided any more.
|
||||
*/
|
||||
init: function(parent) {
|
||||
this._super();
|
||||
|
||||
this.$element = $(document.createElement(this.tag_name));
|
||||
|
||||
this.setParent(parent);
|
||||
|
@ -356,7 +354,7 @@ niv = (function() {
|
|||
if(this.$element != null) {
|
||||
this.$element.remove();
|
||||
}
|
||||
this._super();
|
||||
lib.GetterSetterMixin.destroy.call(this);
|
||||
},
|
||||
/**
|
||||
* Renders the current widget and appends it to the given jQuery object or Widget.
|
||||
|
@ -414,8 +412,6 @@ niv = (function() {
|
|||
},
|
||||
_render_and_insert: function(insertion, target) {
|
||||
this.render_element();
|
||||
if (target instanceof openerp.web.Widget)
|
||||
target = target.$element;
|
||||
insertion(target);
|
||||
return this.start();
|
||||
},
|
||||
|
|
|
@ -2,14 +2,20 @@
|
|||
module("Class");
|
||||
|
||||
test("base", function() {
|
||||
ok(!!niv.Class, "Class does not exist");
|
||||
ok(!!niv.Class.extend, "extend does not exist");
|
||||
ok(!!niv.Class, "Class does exist");
|
||||
ok(!!niv.Class.extend, "extend does exist");
|
||||
var Claz = niv.Class.extend({
|
||||
test: function() {
|
||||
return "ok";
|
||||
}
|
||||
})
|
||||
});
|
||||
equal(new Claz().test(), "ok");
|
||||
var Claz2 = Claz.extend({
|
||||
test: function() {
|
||||
return this._super() + "2";
|
||||
}
|
||||
});
|
||||
equal(new Claz2().test(), "ok2");
|
||||
});
|
||||
|
||||
module("DestroyableMixin");
|
||||
|
@ -93,3 +99,24 @@ test("base", function() {
|
|||
x.set({test: 2});
|
||||
equal(tmp, 1);
|
||||
});
|
||||
|
||||
module("Widget");
|
||||
|
||||
test("base", function() {
|
||||
var Claz = niv.Widget.extend({
|
||||
render_element: function() {
|
||||
this.$element.attr("id", "testdiv");
|
||||
this.$element.html("test");
|
||||
}
|
||||
});
|
||||
var x = new Claz();
|
||||
x.appendTo($("body"));
|
||||
var $el = $("#testdiv");
|
||||
equal($el.length, 1);
|
||||
equal($el.parents()[0], $("body")[0]);
|
||||
equal($el.html(), "test");
|
||||
x.destroy();
|
||||
$el = $("#testdiv");
|
||||
equal($el.length, 0);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue