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('

This is a test

'); 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('
test
'); 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('
test
'); return highlightCode(doHighlight, $) .then(function() { var $code = $('code'); expect($code.text()).toBe('python$test'); }); }); it('should accept async highlighter', function() { var $ = cheerio.load('
test
'); return highlightCode(doHighlightAsync, $) .then(function() { var $code = $('code'); expect($code.text()).toBe('python$test'); }); }); });