@@ -210,6 +210,52 @@ test('engine-munger', function (t) {
210210 } ) ;
211211 } ) ;
212212
213+ t . test ( 'multiple roots - found' , function ( t ) {
214+ var view = makeView ( 'dust' , 'test' , {
215+ root : [
216+ path . resolve ( __dirname , 'fixtures' , 'not-here' ) ,
217+ path . resolve ( __dirname , 'fixtures' , 'templates' )
218+ ]
219+ } ) ;
220+ view . lookupMain ( { } , function ( err ) {
221+ t . error ( err ) ;
222+ t . equal ( view . path , path . resolve ( __dirname , 'fixtures' , 'templates' , 'test.dust' ) ) ;
223+ t . end ( ) ;
224+ } ) ;
225+ } ) ;
226+
227+ t . test ( 'multiple roots - not found' , function ( t ) {
228+ var path1 = path . resolve ( __dirname , 'fixtures' , 'not-here' ) ;
229+ var path2 = path . resolve ( __dirname , 'fixtures' , 'nor-there' )
230+ var view = makeView ( 'dust' , 'test' , {
231+ root : [
232+ path1 ,
233+ path2
234+ ]
235+ } ) ;
236+ view . lookupMain ( { } , function ( err ) {
237+ t . match ( err . message , / F a i l e d t o l o o k u p v i e w " t e s t .d u s t " / ) ;
238+ t . match ( err . message , / n o t - h e r e / ) ;
239+ t . match ( err . message , / n o r - t h e r e / ) ;
240+ t . same ( view . path , true ) ;
241+ t . end ( ) ;
242+ } ) ;
243+ } ) ;
244+
245+ t . test ( 'multiple roots - deferred stat' , function ( t ) {
246+ var view = makeView ( 'dust' , 'test' , { } ) ;
247+ var pending = 0 ;
248+ for ( var i = 0 ; i < 11 ; i ++ ) {
249+ pending ++ ;
250+ view . lookup ( 'test' , { } , function ( err ) {
251+ t . error ( err ) ;
252+ if ( -- pending === 0 ) {
253+ t . end ( ) ;
254+ }
255+ } ) ;
256+ }
257+ } ) ;
258+
213259} ) ;
214260
215261function makeView ( ext , tmpl , config ) {
@@ -219,7 +265,7 @@ function makeView(ext, tmpl, config) {
219265 var engines = { } ;
220266 engines [ '.' + ext ] = adaro [ ext ] ( ) ;
221267 return new View ( tmpl , {
222- root : ext == 'js' ? path . resolve ( __dirname , 'fixtures/.build' ) : path . resolve ( __dirname , 'fixtures/templates' ) ,
268+ root : config . root ? config . root : ext == 'js' ? path . resolve ( __dirname , 'fixtures/.build' ) : path . resolve ( __dirname , 'fixtures/templates' ) ,
223269 defaultEngine : '.' + ext ,
224270 engines : engines
225271 } ) ;
0 commit comments