File tree Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3+ const _ = require ( 'lodash' ) ;
4+
35const uikitExcludePattern = ( pattern , uikit ) => {
46 const state = pattern . patternState ;
5- return uikit . excludedPatternStates . includes ( state ) ;
7+ const tags = _ . isArray ( pattern . tags ) ? pattern . tags : [ pattern . tags ] ;
8+
9+ return (
10+ _ . includes ( uikit . excludedPatternStates , state ) ||
11+ _ . intersection ( uikit . excludedTags , tags ) . length > 0
12+ ) ;
613} ;
714module . exports = uikitExcludePattern ;
Original file line number Diff line number Diff line change @@ -51,3 +51,51 @@ tap.test(
5151 test . end ( ) ;
5252 }
5353) ;
54+
55+ tap . test (
56+ 'uikitExcludePattern - returns false when uikit has no excluded tags' ,
57+ test => {
58+ //arrange
59+ const uikit = { excludedTags : [ ] } ;
60+ const pattern = { tags : 'foo-tag' } ;
61+
62+ //act
63+ const result = uikitExcludePattern ( pattern , uikit ) ;
64+
65+ //assert
66+ test . false ( result ) ;
67+ test . end ( ) ;
68+ }
69+ ) ;
70+
71+ tap . test (
72+ 'uikitExcludePattern - returns false pattern does not have same tags as uikit exclusions' ,
73+ test => {
74+ //arrange
75+ const uikit = { excludedTags : [ 'bat-tag' ] } ;
76+ const pattern = { tags : 'foo-tag' } ;
77+
78+ //act
79+ const result = uikitExcludePattern ( pattern , uikit ) ;
80+
81+ //assert
82+ test . false ( result ) ;
83+ test . end ( ) ;
84+ }
85+ ) ;
86+
87+ tap . test (
88+ 'uikitExcludePattern - returns true when uikit has same tags as pattern' ,
89+ test => {
90+ //arrange
91+ const uikit = { excludedTags : [ 'bar-tag' , 'foo-tag' ] } ;
92+ const pattern = { tags : 'foo-tag' } ;
93+
94+ //act
95+ const result = uikitExcludePattern ( pattern , uikit ) ;
96+
97+ //assert
98+ test . true ( result ) ;
99+ test . end ( ) ;
100+ }
101+ ) ;
You can’t perform that action at this time.
0 commit comments