Merge branch 'master' into develop

This commit is contained in:
Estevao Soares dos Santos 2017-03-30 23:17:56 +01:00
commit f1eab2a7f2
2 changed files with 26 additions and 0 deletions

View File

@ -114,6 +114,7 @@ showdown.setFlavor = function (name) {
if (!flavor.hasOwnProperty(name)) { if (!flavor.hasOwnProperty(name)) {
throw Error(name + ' flavor was not found'); throw Error(name + ' flavor was not found');
} }
showdown.resetOptions();
var preset = flavor[name]; var preset = flavor[name];
setFlavor = name; setFlavor = name;
for (var option in preset) { for (var option in preset) {

View File

@ -130,4 +130,29 @@ describe('showdown.setFlavor()', function () {
} }
showdown.setFlavor('vanilla'); showdown.setFlavor('vanilla');
}); });
it('should switch between flavors correctly', function () {
showdown.setFlavor('github');
var ghOpts = showdown.getFlavorOptions('github'),
shOpts = showdown.getOptions(),
dfOpts = showdown.getDefaultOptions();
for (var opt in dfOpts) {
if (ghOpts.hasOwnProperty(opt)) {
shOpts[opt].should.equal(ghOpts[opt]);
} else {
shOpts[opt].should.equal(dfOpts[opt]);
}
}
showdown.setFlavor('original');
var orOpts = showdown.getFlavorOptions('original');
shOpts = showdown.getOptions();
for (opt in dfOpts) {
if (orOpts.hasOwnProperty(opt)) {
shOpts[opt].should.equal(orOpts[opt]);
} else {
shOpts[opt].should.equal(dfOpts[opt]);
}
}
showdown.setFlavor('vanilla');
});
}); });