diff --git a/core/server/lib/mobiledoc.js b/core/server/lib/mobiledoc.js index 32a86b1f9f..6ef6681241 100644 --- a/core/server/lib/mobiledoc.js +++ b/core/server/lib/mobiledoc.js @@ -28,7 +28,8 @@ module.exports = { cardFactory = new CardFactory({ siteUrl: config.get('url'), - contentImageSizes: config.get('imageOptimization:contentImageSizes') + contentImageSizes: config.get('imageOptimization:contentImageSizes'), + srcsets: config.get('imageOptimization:srcsets') }); cards = defaultCards.map((card) => { @@ -75,5 +76,12 @@ module.exports = { }); }; } + }, + + // allow config changes to be picked up - useful in tests + reload() { + cardFactory = null; + cards = null; + mobiledocHtmlRenderer = null; } }; diff --git a/core/shared/config/defaults.json b/core/shared/config/defaults.json index 159e443566..342cf77068 100644 --- a/core/shared/config/defaults.json +++ b/core/shared/config/defaults.json @@ -102,7 +102,8 @@ } }, "imageOptimization": { - "resize": true + "resize": true, + "srcsets": true }, "compress": true, "preloadHeaders": false, diff --git a/test/unit/lib/mobiledoc_spec.js b/test/unit/lib/mobiledoc_spec.js index a14402581b..2d16c8681a 100644 --- a/test/unit/lib/mobiledoc_spec.js +++ b/test/unit/lib/mobiledoc_spec.js @@ -9,6 +9,8 @@ describe('lib/mobiledoc', function () { afterEach(function () { configUtils.restore(); + // ensure config changes are reset and picked up by next test + mobiledocLib.reload(); }); describe('mobiledocHtmlRenderer', function () { @@ -72,5 +74,40 @@ describe('lib/mobiledoc', function () { mobiledocLib.mobiledocHtmlRenderer.render(mobiledoc) .should.eql('
One
Two
Some markdown
\nThree
Four
Some HTML