Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function build(treeFn, version) {
let post = PostAbstractHelpers.build(treeFn);
switch (version) {
case MOBILEDOC_VERSION_0_2:
return MobiledocRenderer_0_2.render(post);
case MOBILEDOC_VERSION_0_3:
return MobiledocRenderer_0_3.render(post);
case MOBILEDOC_VERSION_0_3_1:
return MobiledocRenderer_0_3_1.render(post);
case MOBILEDOC_VERSION_0_3_2:
return MobiledocRenderer_0_3_2.render(post);
case undefined:
case null:
return mobiledocRenderers.render(post);
default:
throw new Error(`Unknown version of mobiledoc renderer requested: ${version}`);
}
}
QUnit.assert.postIsSimilar = function(post, expected, postName='post') {
comparePostNode(post, expected, this, postName, true);
let mobiledoc = mobiledocRenderers.render(post),
expectedMobiledoc = mobiledocRenderers.render(expected);
this.deepEqual(mobiledoc, expectedMobiledoc,
`${postName} is similar to expected`);
};
QUnit.assert.postIsSimilar = function(post, expected, postName='post') {
comparePostNode(post, expected, this, postName, true);
let mobiledoc = mobiledocRenderers.render(post),
expectedMobiledoc = mobiledocRenderers.render(expected);
this.deepEqual(mobiledoc, expectedMobiledoc,
`${postName} is similar to expected`);
};
function renderPostInto(element, post, editorOptions={}) {
let mobiledoc = mobiledocRenderers.render(post);
mergeWithOptions(editorOptions, {mobiledoc});
let editor = new Editor(editorOptions);
editor.render(element);
return editor;
}