test(option.prefixHeaderId): add tests for prefixHeaderId option

This commit is contained in:
Estevão Soares dos Santos 2015-05-27 01:48:49 +01:00
parent 6492e74c5b
commit 2a4a2bdf21

View File

@ -45,6 +45,25 @@
});
});
describe('Converter.options prefixHeaderId', function () {
var converter = new showdown.Converter(),
text = 'foo header';
it('should prefix header id with "section"', function () {
converter.setOption('prefixHeaderId', true);
var html = converter.makeHtml('# ' + text),
expectedHtml = '<h1 id="sectionfooheader">' + text + '</h1>';
html.should.equal(expectedHtml);
});
it('should prefix header id with custom string', function () {
converter.setOption('prefixHeaderId', 'blabla');
var html = converter.makeHtml('# ' + text),
expectedHtml = '<h1 id="blablafooheader">' + text + '</h1>';
html.should.equal(expectedHtml);
});
});
function filter() {
return function (file) {
var ext = file.slice(-3);