@@ -153,38 +153,48 @@ describe('precompiler', function() {
153
153
} ) ;
154
154
155
155
describe ( '#loadTemplates' , function ( ) {
156
- it ( 'should throw on missing template' , function ( ) {
157
- shouldThrow ( function ( ) {
158
- Precompiler . loadTemplates ( { templates : [ 'foo' ] } ) ;
159
- } , Handlebars . Exception , 'Unable to open template file "foo"' ) ;
156
+ it ( 'should throw on missing template' , function ( done ) {
157
+ Precompiler . loadTemplates ( { files : [ 'foo' ] } , function ( err ) {
158
+ equal ( err . message , 'Unable to open template file "foo"' ) ;
159
+ done ( ) ;
160
+ } ) ;
160
161
} ) ;
161
- it ( 'should enumerate directories by extension' , function ( ) {
162
- var opts = { templates : [ __dirname + '/artifacts' ] , extension : 'hbs' } ;
163
- Precompiler . loadTemplates ( opts ) ;
164
- equal ( opts . templates . length , 1 ) ;
165
- equal ( opts . templates [ 0 ] . name , 'example_2' ) ;
166
-
167
- opts = { templates : [ __dirname + '/artifacts' ] , extension : 'handlebars' } ;
168
- Precompiler . loadTemplates ( opts ) ;
169
- equal ( opts . templates . length , 3 ) ;
170
- equal ( opts . templates [ 0 ] . name , 'bom' ) ;
171
- equal ( opts . templates [ 1 ] . name , 'empty' ) ;
172
- equal ( opts . templates [ 2 ] . name , 'example_1' ) ;
162
+ it ( 'should enumerate directories by extension' , function ( done ) {
163
+ Precompiler . loadTemplates ( { files : [ __dirname + '/artifacts' ] , extension : 'hbs' } , function ( err , opts ) {
164
+ equal ( opts . templates . length , 1 ) ;
165
+ equal ( opts . templates [ 0 ] . name , 'example_2' ) ;
166
+ done ( err ) ;
167
+ } ) ;
173
168
} ) ;
174
- it ( 'should handle regular expression characters in extensions' , function ( ) {
175
- Precompiler . loadTemplates ( { templates : [ __dirname + '/artifacts' ] , extension : 'hb(s' } ) ;
176
- // Success is not throwing
169
+ it ( 'should enumerate all templates by extension' , function ( done ) {
170
+ Precompiler . loadTemplates ( { files : [ __dirname + '/artifacts' ] , extension : 'handlebars' } , function ( err , opts ) {
171
+ equal ( opts . templates . length , 3 ) ;
172
+ equal ( opts . templates [ 0 ] . name , 'bom' ) ;
173
+ equal ( opts . templates [ 1 ] . name , 'empty' ) ;
174
+ equal ( opts . templates [ 2 ] . name , 'example_1' ) ;
175
+ done ( err ) ;
176
+ } ) ;
177
177
} ) ;
178
- it ( 'should handle BOM' , function ( ) {
179
- var opts = { templates : [ __dirname + '/artifacts/bom.handlebars' ] , extension : 'handlebars' , bom : true } ;
180
- Precompiler . loadTemplates ( opts ) ;
181
- equal ( opts . templates [ 0 ] . source , 'a' ) ;
178
+ it ( 'should handle regular expression characters in extensions' , function ( done ) {
179
+ Precompiler . loadTemplates ( { files : [ __dirname + '/artifacts' ] , extension : 'hb(s' } , function ( err ) {
180
+ // Success is not throwing
181
+ done ( err ) ;
182
+ } ) ;
183
+ } ) ;
184
+ it ( 'should handle BOM' , function ( done ) {
185
+ var opts = { files : [ __dirname + '/artifacts/bom.handlebars' ] , extension : 'handlebars' , bom : true } ;
186
+ Precompiler . loadTemplates ( opts , function ( err , opts ) {
187
+ equal ( opts . templates [ 0 ] . source , 'a' ) ;
188
+ done ( err ) ;
189
+ } ) ;
182
190
} ) ;
183
191
184
- it ( 'should handle different root' , function ( ) {
185
- var opts = { templates : [ __dirname + '/artifacts/empty.handlebars' ] , simple : true , root : 'foo/' } ;
186
- Precompiler . loadTemplates ( opts ) ;
187
- equal ( opts . templates [ 0 ] . name , __dirname + '/artifacts/empty' ) ;
192
+ it ( 'should handle different root' , function ( done ) {
193
+ var opts = { files : [ __dirname + '/artifacts/empty.handlebars' ] , simple : true , root : 'foo/' } ;
194
+ Precompiler . loadTemplates ( opts , function ( err , opts ) {
195
+ equal ( opts . templates [ 0 ] . name , __dirname + '/artifacts/empty' ) ;
196
+ done ( err ) ;
197
+ } ) ;
188
198
} ) ;
189
199
} ) ;
190
200
} ) ;
0 commit comments