From 2d1b59faa0fb8b33db3c5f99e2e049bf3792e870 Mon Sep 17 00:00:00 2001 From: Matthew Beale Date: Thu, 19 Nov 2015 16:36:49 -0500 Subject: [PATCH] Use more constants for mobiledoc versions --- src/js/parsers/mobiledoc/index.js | 3 ++- src/js/renderers/mobiledoc/index.js | 2 +- tests/helpers/mobiledoc.js | 9 +++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/js/parsers/mobiledoc/index.js b/src/js/parsers/mobiledoc/index.js index a310bdf30..373d4b1dc 100644 --- a/src/js/parsers/mobiledoc/index.js +++ b/src/js/parsers/mobiledoc/index.js @@ -1,4 +1,5 @@ import MobiledocParser_0_2 from './0-2'; +import { MOBILEDOC_VERSION } from 'mobiledoc-kit/renderers/mobiledoc/0-2'; function parseVersion(mobiledoc) { return mobiledoc.version; @@ -8,7 +9,7 @@ export default { parse(builder, mobiledoc) { let version = parseVersion(mobiledoc); switch (version) { - case '0.2.0': + case MOBILEDOC_VERSION: return new MobiledocParser_0_2(builder).parse(mobiledoc); default: throw new Error(`Unknown version of mobiledoc parser requested: ${version}`); diff --git a/src/js/renderers/mobiledoc/index.js b/src/js/renderers/mobiledoc/index.js index 3fb6d925e..d6a9b9571 100644 --- a/src/js/renderers/mobiledoc/index.js +++ b/src/js/renderers/mobiledoc/index.js @@ -5,7 +5,7 @@ export { MOBILEDOC_VERSION }; export default { render(post, version) { switch (version) { - case '0.2.0': + case MOBILEDOC_VERSION: case undefined: case null: return MobiledocRenderer_0_2.render(post); diff --git a/tests/helpers/mobiledoc.js b/tests/helpers/mobiledoc.js index 929407bc7..540f0f845 100644 --- a/tests/helpers/mobiledoc.js +++ b/tests/helpers/mobiledoc.js @@ -1,6 +1,6 @@ import PostAbstractHelpers from './post-abstract'; import mobiledocRenderers from 'mobiledoc-kit/renderers/mobiledoc'; -import MobiledocRenderer_0_2 from 'mobiledoc-kit/renderers/mobiledoc/0-2'; +import MobiledocRenderer_0_2, { MOBILEDOC_VERSION } from 'mobiledoc-kit/renderers/mobiledoc/0-2'; /* * usage: @@ -13,12 +13,13 @@ import MobiledocRenderer_0_2 from 'mobiledoc-kit/renderers/mobiledoc/0-2'; * ) */ function build(treeFn, version) { + let post = PostAbstractHelpers.build(treeFn); switch (version) { - case '0.2.0': - return MobiledocRenderer_0_2.render(PostAbstractHelpers.build(treeFn)); + case MOBILEDOC_VERSION: + return MobiledocRenderer_0_2.render(post); case undefined: case null: - return mobiledocRenderers.render(PostAbstractHelpers.build(treeFn)); + return mobiledocRenderers.render(post); default: throw new Error(`Unknown version of mobiledoc renderer requested: ${version}`); }