-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcomment-tests.js
70 lines (60 loc) · 1.48 KB
/
comment-tests.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
require('should');
var helpers = require('./helpers');
describe('Comments', function() {
it('inside tags', function() {
var commentCount = 0;
helpers.parseString('<foo><!-- foo bar --></foo>', {
comment: function(value) {
value.should.equal(' foo bar ');
commentCount++;
}
});
commentCount.should.equal(1);
});
it('spanning multiple lines', function() {
var commentCount = 0;
helpers.parseString('<!-- foo \nbar -->', {
comment: function(value) {
value.should.equal(' foo \nbar ');
commentCount++;
}
});
commentCount.should.equal(1);
});
it('allow tags and entities', function() {
var commentCount = 0;
helpers.parseString('<!-- foo & <bar> -->', {
comment: function(value) {
value.should.equal(' foo & <bar> ');
commentCount++;
}
});
commentCount.should.equal(1);
});
it('read to EOF if --> is not given', function() {
var commentCount = 0;
helpers.parseString('<!-- foo', {
comment: function(value) {
value.should.equal(' foo');
commentCount++;
}
});
commentCount.should.equal(1);
});
it('outputs buffered text node before comment', function() {
var commentCount = 0, textCount = 0;
helpers.parseString('foo<!-- bar -->', {
text: function(value) {
value.should.equal('foo');
textCount++;
},
comment: function(value) {
textCount.should.equal(1);
value.should.equal(' bar ');
commentCount++;
}
});
commentCount.should.equal(1);
textCount.should.equal(1);
});
});