var DOM = require('../src/dom.js').DOM;
describe('dom', function() {
var dom;
beforeEach(function() {
dom = new DOM();
});
describe('h', function() {
it('should render using function', function() {
var cbThis;
var cdValue;
dom.h('heading', 'content', function(value){
cbThis = this;
cbValue = value;
});
expect(cbThis).toEqual(dom);
expect(cbValue).toEqual('content');
});
it('should update heading numbers', function() {
dom.h('heading', function() {
this.html('
sub-heading
');
});
expect(dom.toString()).toContain('heading
');
expect(dom.toString()).toContain('sub-heading
');
});
it('should properly number nested headings', function() {
dom.h('heading', function() {
dom.h('heading2', function() {
this.html('heading3
');
});
});
dom.h('other1', function() {
this.html('other2
');
});
expect(dom.toString()).toContain('heading
');
expect(dom.toString()).toContain('heading2
');
expect(dom.toString()).toContain('heading3
');
expect(dom.toString()).toContain('other1
');
expect(dom.toString()).toContain('other2
');
});
});
});