1 define(function(require) {
4 /* globals describe, it */
7 var ElementsRegister = require('./elementsRegister.js'),
8 documentElement = require('./documentElement.js'),
9 chai = require('libs/chai');
11 var expect = chai.expect;
13 describe('Elements register', function() {
14 it('registers element for a tag', function() {
15 var register = new ElementsRegister(documentElement.DocumentNodeElement),
16 prototype = {testMethod: function(){}};
23 var Element = register.getElement({tag: 'div'});
24 expect(Element.prototype.testMethod).to.equal(prototype.testMethod, '1');
25 expect(Element.prototype instanceof documentElement.DocumentNodeElement).to.equal(true, '2');
27 it('registers element for a class', function() {
28 var register = new ElementsRegister(documentElement.DocumentNodeElement),
29 prototype = {testMethod: function(){}};
36 var Element = register.getElement({tag: 'div', klass: 'a.b.c'});
37 expect(Element.prototype.testMethod).to.equal(prototype.testMethod, '1');
38 expect(Element.prototype instanceof documentElement.DocumentNodeElement).to.equal(true, '2');
40 it('allows inheriting from selected element', function() {
41 var register = new ElementsRegister(documentElement.DocumentNodeElement),
42 method1 = function() {},
43 method2 = function() {};
47 prototype: {method1: method1}
53 prototype: {method2: method2},
54 extending: {tag: 'div'}
57 var Element = register.getElement({tag: 'div', klass: 'a'});
58 expect(Element.prototype.method2).to.equal(method2, '2');
59 expect(Element.prototype instanceof register.getElement({tag: 'div'})).to.equal(true, '2');