@@ -34,8 +34,8 @@ const initialise = function () {
3434 return { local : local , fs : fsMock } ;
3535} ;
3636
37- const executeComponentsListingByDir = function ( local ) {
38- return local ( '.' ) ;
37+ const executeComponentsListingByDir = function ( local , componentsToRun ) {
38+ return local ( '.' , componentsToRun ) ;
3939} ;
4040
4141describe ( 'cli : domain : get-components-by-dir' , ( ) => {
@@ -140,4 +140,43 @@ describe('cli : domain : get-components-by-dir', () => {
140140 expect ( result ) . to . eql ( [ ] ) ;
141141 } ) ;
142142 } ) ;
143+
144+ describe ( 'when components are filtered' , ( ) => {
145+ let error ;
146+ let result ;
147+ beforeEach ( done => {
148+ const data = initialise ( ) ;
149+
150+ data . fs . readdir
151+ . onCall ( 0 )
152+ . resolves ( [
153+ 'component1' ,
154+ 'component2' ,
155+ 'component3' ,
156+ 'component4' ,
157+ 'package.json'
158+ ] ) ;
159+
160+ data . fs . readJsonSync . onCall ( 0 ) . returns ( { oc : { } } ) ;
161+ data . fs . readJsonSync . onCall ( 1 ) . returns ( { oc : { } } ) ;
162+ data . fs . readJsonSync . onCall ( 2 ) . returns ( { oc : { } } ) ;
163+ data . fs . readJsonSync . onCall ( 3 ) . returns ( { oc : { } } ) ;
164+ data . fs . readJsonSync
165+ . onCall ( 4 )
166+ . throws ( new Error ( 'ENOENT: no such file or directory' ) ) ;
167+
168+ executeComponentsListingByDir ( data . local , [ 'component1' , 'component3' ] )
169+ . then ( res => ( result = res ) )
170+ . catch ( err => ( error = err ) )
171+ . finally ( done ) ;
172+ } ) ;
173+
174+ it ( 'should not error' , ( ) => {
175+ expect ( error ) . to . be . undefined ;
176+ } ) ;
177+
178+ it ( 'should get an the filtered list' , ( ) => {
179+ expect ( result ) . to . eql ( [ './component1' , './component3' ] ) ;
180+ } ) ;
181+ } ) ;
143182} ) ;
0 commit comments