diff --git a/packages/core/src/lib/uikitExcludePattern.js b/packages/core/src/lib/uikitExcludePattern.js index 61cddcb57..22aa3eece 100644 --- a/packages/core/src/lib/uikitExcludePattern.js +++ b/packages/core/src/lib/uikitExcludePattern.js @@ -1,7 +1,14 @@ 'use strict'; +const _ = require('lodash'); + const uikitExcludePattern = (pattern, uikit) => { const state = pattern.patternState; - return uikit.excludedPatternStates.includes(state); + const tags = _.isArray(pattern.tags) ? pattern.tags : [pattern.tags]; + + return ( + _.includes(uikit.excludedPatternStates, state) || + _.intersection(uikit.excludedTags, tags).length > 0 + ); }; module.exports = uikitExcludePattern; diff --git a/packages/core/test/uikitExcludePattern_tests.js b/packages/core/test/uikitExcludePattern_tests.js index a31f4c3f3..fbde9d5e8 100644 --- a/packages/core/test/uikitExcludePattern_tests.js +++ b/packages/core/test/uikitExcludePattern_tests.js @@ -51,3 +51,51 @@ tap.test( test.end(); } ); + +tap.test( + 'uikitExcludePattern - returns false when uikit has no excluded tags', + test => { + //arrange + const uikit = { excludedTags: [] }; + const pattern = { tags: 'foo-tag' }; + + //act + const result = uikitExcludePattern(pattern, uikit); + + //assert + test.false(result); + test.end(); + } +); + +tap.test( + 'uikitExcludePattern - returns false pattern does not have same tags as uikit exclusions', + test => { + //arrange + const uikit = { excludedTags: ['bat-tag'] }; + const pattern = { tags: 'foo-tag' }; + + //act + const result = uikitExcludePattern(pattern, uikit); + + //assert + test.false(result); + test.end(); + } +); + +tap.test( + 'uikitExcludePattern - returns true when uikit has same tags as pattern', + test => { + //arrange + const uikit = { excludedTags: ['bar-tag', 'foo-tag'] }; + const pattern = { tags: 'foo-tag' }; + + //act + const result = uikitExcludePattern(pattern, uikit); + + //assert + test.true(result); + test.end(); + } +);