From 04dc6c04347ee44acf11f0a6c210cc4aed388716 Mon Sep 17 00:00:00 2001 From: Yuliy Vigdorchik Date: Tue, 29 May 2018 11:23:30 -0400 Subject: [PATCH] Never let getStyleFiles throw an error, complete branch coverage also --- lib/media.js | 2 +- lib/media.test.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/media.js b/lib/media.js index 39e960d..86347d3 100644 --- a/lib/media.js +++ b/lib/media.js @@ -182,7 +182,7 @@ function getStyleFiles(state) { assetPath = site && site.assetPath || '', assetHost = site && site.assetHost || '', siteStyleguide = site && site.styleguide; - let cssFilePaths; + let cssFilePaths = []; // legacy behavior: load .css and ..css if (!site.styleguide) { diff --git a/lib/media.test.js b/lib/media.test.js index 6d9f5cf..8690785 100644 --- a/lib/media.test.js +++ b/lib/media.test.js @@ -195,6 +195,22 @@ describe(_.startCase(filename), function () { ]); }); + it('returns no styles when there is a style guide but no _usedVariations object', function () { + const localState = { + locals: { + edit: true, + site: { + slug: 'foo', + assetDir: '/foo', + styleguide: 'bar' + } + }, + _components: [] + }; + + expect(fn(localState)).to.deep.equal([]); + }); + describe('with no site styleguide (legacy)', function () { it('handles an empty component list', function () { expect(fn({