Skip to content

Commit

Permalink
Never let getStyleFiles throw an error, complete branch coverage also
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuliy Vigdorchik committed May 29, 2018
1 parent 474973b commit 04dc6c0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <component>.css and <component>.<site>.css
if (!site.styleguide) {
Expand Down
16 changes: 16 additions & 0 deletions lib/media.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 04dc6c0

Please sign in to comment.