2011-10-17 22:26:10 +00:00
|
|
|
var DOM = require('../src/dom.js').DOM;
|
2011-01-19 23:42:11 +00:00
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
describe('dom', function() {
|
2011-01-26 05:55:11 +00:00
|
|
|
var dom;
|
|
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
beforeEach(function() {
|
2011-01-26 05:55:11 +00:00
|
|
|
dom = new DOM();
|
|
|
|
|
});
|
|
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
describe('h', function() {
|
2011-01-26 05:55:11 +00:00
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
it('should render using function', function() {
|
2011-01-26 05:55:11 +00:00
|
|
|
var cbThis;
|
|
|
|
|
var cdValue;
|
|
|
|
|
dom.h('heading', 'content', function(value){
|
|
|
|
|
cbThis = this;
|
|
|
|
|
cbValue = value;
|
|
|
|
|
});
|
|
|
|
|
expect(cbThis).toEqual(dom);
|
|
|
|
|
expect(cbValue).toEqual('content');
|
|
|
|
|
});
|
|
|
|
|
|
2011-10-07 18:27:49 +00:00
|
|
|
it('should update heading numbers', function() {
|
|
|
|
|
dom.h('heading', function() {
|
2011-01-26 05:55:11 +00:00
|
|
|
this.html('<h1>sub-heading</h1>');
|
|
|
|
|
});
|
2011-11-10 05:18:34 +00:00
|
|
|
expect(dom.toString()).toContain('<h1 id="heading">heading</h1>');
|
2011-01-26 05:55:11 +00:00
|
|
|
expect(dom.toString()).toContain('<h2>sub-heading</h2>');
|
|
|
|
|
});
|
2011-01-19 23:42:11 +00:00
|
|
|
|
2013-05-20 21:02:03 +00:00
|
|
|
it('should properly number nested headings', function() {
|
|
|
|
|
dom.h('heading', function() {
|
|
|
|
|
dom.h('heading2', function() {
|
|
|
|
|
this.html('<h1>heading3</h1>');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
dom.h('other1', function() {
|
|
|
|
|
this.html('<h1>other2</h1>');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
expect(dom.toString()).toContain('<h1 id="heading">heading</h1>');
|
|
|
|
|
expect(dom.toString()).toContain('<h2 id="heading2">heading2</h2>');
|
|
|
|
|
expect(dom.toString()).toContain('<h3>heading3</h3>');
|
|
|
|
|
|
|
|
|
|
expect(dom.toString()).toContain('<h1 id="other1">other1</h1>');
|
|
|
|
|
expect(dom.toString()).toContain('<h2>other2</h2>');
|
|
|
|
|
});
|
|
|
|
|
|
2011-01-19 23:42:11 +00:00
|
|
|
});
|
2011-01-26 05:55:11 +00:00
|
|
|
|
2011-01-19 23:42:11 +00:00
|
|
|
});
|