describe('Elements register', function() {
it('registers element for a tag', function() {
var register = new ElementsRegister(documentElement.DocumentNodeElement),
- prototype = {testMethod: function(){}};
+ prototype = Object.create({});
register.register({
tag: 'div',
prototype: prototype,
});
-
var Element = register.getElement({tag: 'div'});
- expect(Element.prototype.testMethod).to.equal(prototype.testMethod, '1');
- expect(Element.prototype instanceof documentElement.DocumentNodeElement).to.equal(true, '2');
+ expect(Element.prototype).to.equal(prototype);
});
it('registers element for a class', function() {
var register = new ElementsRegister(documentElement.DocumentNodeElement),
- prototype = {testMethod: function(){}};
+ prototype = Object.create({});
register.register({
tag: 'div',
prototype: prototype,
});
var Element = register.getElement({tag: 'div', klass: 'a.b.c'});
- expect(Element.prototype.testMethod).to.equal(prototype.testMethod, '1');
- expect(Element.prototype instanceof documentElement.DocumentNodeElement).to.equal(true, '2');
- });
- it('allows inheriting from selected element', function() {
- var register = new ElementsRegister(documentElement.DocumentNodeElement),
- method1 = function() {},
- method2 = function() {};
-
- register.register({
- tag: 'div',
- prototype: {method1: method1}
- });
-
- register.register({
- tag: 'div',
- klass: 'a',
- prototype: {method2: method2},
- extending: {tag: 'div'}
- });
-
- var Element = register.getElement({tag: 'div', klass: 'a'});
- expect(Element.prototype.method2).to.equal(method2, '2');
- expect(Element.prototype instanceof register.getElement({tag: 'div'})).to.equal(true, '2');
+ expect(Element.prototype).to.equal(prototype);
});
});