blob: 75d99022e642ba7775d4c0791ff19bcb5e1c4858 (
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
52
53
54
55
56
57
58
59
60
|
var cheerio = require('cheerio');
var Promise = require('../../../utils/promise');
var highlightCode = require('../highlightCode');
describe('highlightCode', function() {
function doHighlight(lang, code) {
return {
text: '' + (lang || '') + '$' + code
};
}
function doHighlightAsync(lang, code) {
return Promise()
.then(function() {
return doHighlight(lang, code);
});
}
it('should call it for normal code element', function() {
var $ = cheerio.load('<p>This is a <code>test</code></p>');
return highlightCode(doHighlight, $)
.then(function() {
var $code = $('code');
expect($code.text()).toBe('$test');
});
});
it('should call it for markdown code block', function() {
var $ = cheerio.load('<pre><code class="lang-js">test</code></pre>');
return highlightCode(doHighlight, $)
.then(function() {
var $code = $('code');
expect($code.text()).toBe('js$test');
});
});
it('should call it for asciidoc code block', function() {
var $ = cheerio.load('<pre><code class="language-python">test</code></pre>');
return highlightCode(doHighlight, $)
.then(function() {
var $code = $('code');
expect($code.text()).toBe('python$test');
});
});
it('should accept async highlighter', function() {
var $ = cheerio.load('<pre><code class="language-python">test</code></pre>');
return highlightCode(doHighlightAsync, $)
.then(function() {
var $code = $('code');
expect($code.text()).toBe('python$test');
});
});
});
|