blob: 7bc6a7f4b25cc14c8fe7802680098e8b20354701 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
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('<h1>sub-heading</h1>');
});
expect(dom.toString()).toContain('<h1 id="heading">heading</h1>');
expect(dom.toString()).toContain('<h2>sub-heading</h2>');
});
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>');
});
});
});
|