mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
4ebd0caa27
Old extensions that register themselves in `showdown.extensions` can be loaded and validated using the new extension loading mechanism. However, a warn is issued, alerting users and developers that the extension should be updated to use the new mechanism BREAKING CHANGE: Deprecates `showdown.extensions` property. To migrate, you should use the new method `showdown.extension(<ext name>, <extension>)` to register the extension.
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
/**
|
|
* Created by Estevao on 31-05-2015.
|
|
*/
|
|
require('source-map-support').install();
|
|
require('chai').should();
|
|
require('sinon');
|
|
var showdown = require('../../dist/showdown.js');
|
|
|
|
describe('showdown.Converter', function () {
|
|
'use strict';
|
|
|
|
describe('option methods', function () {
|
|
var converter = new showdown.Converter();
|
|
|
|
it('setOption() should set option foo=baz', function () {
|
|
converter.setOption('foo', 'baz');
|
|
});
|
|
|
|
it('getOption() should get option foo to equal baz', function () {
|
|
converter.getOption('foo').should.equal('baz');
|
|
});
|
|
|
|
it('getOptions() should contain foo=baz', function () {
|
|
var options = converter.getOptions();
|
|
options.should.have.ownProperty('foo');
|
|
options.foo.should.equal('baz');
|
|
});
|
|
});
|
|
|
|
describe('extension methods', function () {
|
|
var extObjMock = {
|
|
type: 'lang',
|
|
filter: function () {}
|
|
},
|
|
extObjFunc = function () {
|
|
return extObjMock;
|
|
};
|
|
|
|
it('addExtension() should add an extension Object', function () {
|
|
var converter = new showdown.Converter();
|
|
converter.addExtension(extObjMock);
|
|
converter.getAllExtensions().language.should.contain(extObjMock);
|
|
});
|
|
|
|
it('addExtension() should unwrap an extension wrapped in a function', function () {
|
|
var converter = new showdown.Converter();
|
|
|
|
converter.addExtension(extObjFunc);
|
|
converter.getAllExtensions().language.should.contain(extObjMock);
|
|
});
|
|
|
|
it('useExtension() should use a previous registered extension in showdown', function () {
|
|
showdown.extension('foo', extObjMock);
|
|
var converter = new showdown.Converter();
|
|
|
|
converter.useExtension('foo');
|
|
converter.getAllExtensions().language.should.contain(extObjMock);
|
|
showdown.resetExtensions();
|
|
});
|
|
});
|
|
});
|