@@ -14,27 +14,40 @@ const compile = function(data) {
1414 } ) ;
1515}
1616
17+ const compileSync = function ( data ) {
18+ return new Promise ( ( yeah , nah ) => {
19+ try {
20+ const results = sass . renderSync ( { data, importer : importer } ) ;
21+ yeah ( results . css . toString ( ) ) ;
22+ } catch ( err ) {
23+ nah ( err ) ;
24+ }
25+ } ) ;
26+ }
27+
1728describe ( 'node-module-importer' , ( ) => {
18- describe ( 'async' , ( ) => {
19- it ( 'should resolve Sass @import from npm packages' , ( ) => (
20- compile ( '@import "foundation/scss/foundation.scss"' )
21- . then ( result => expect ( result === foundation ) . toBeTruthy ( ) )
22- ) ) ;
23- it ( 'should resolve Sass @import without extension from npm packages' , ( ) => (
24- compile ( '@import "foundation/scss/foundation.scss"' )
25- . then ( result => expect ( result === foundation ) . toBeTruthy ( ) )
26- ) ) ;
27- it ( 'should resolve Sass @import for partials from npm packages' , ( ) => (
28- compile ( '@import "foundation/scss/foundation/_variables.scss"' )
29- ) ) ;
30- it ( 'should resolve Sass @import for partials without extension from npm packages' , ( ) => (
31- compile ( '@import "foundation/scss/foundation/_variables"' )
32- ) ) ;
33- it ( 'should resolve Sass @import for partials without underscore from npm packages' , ( ) => (
34- compile ( '@import "foundation/scss/foundation/variables.scss"' )
35- ) ) ;
36- it ( 'should resolve Sass @import for partials without underscore and extension from npm packages' , ( ) => (
37- compile ( '@import "foundation/scss/foundation/variables"' )
38- ) ) ;
29+ [ [ 'async' , compile ] , [ 'sync' , compileSync ] ] . forEach ( ( [ label , func ] ) => {
30+ describe ( label , ( ) => {
31+ it ( 'should resolve Sass @import from npm packages' , ( ) => (
32+ func ( '@import "foundation/scss/foundation.scss"' )
33+ . then ( result => expect ( result === foundation ) . toBeTruthy ( ) )
34+ ) ) ;
35+ it ( 'should resolve Sass @import without extension from npm packages' , ( ) => (
36+ func ( '@import "foundation/scss/foundation.scss"' )
37+ . then ( result => expect ( result === foundation ) . toBeTruthy ( ) )
38+ ) ) ;
39+ it ( 'should resolve Sass @import for partials from npm packages' , ( ) => (
40+ func ( '@import "foundation/scss/foundation/_variables.scss"' )
41+ ) ) ;
42+ it ( 'should resolve Sass @import for partials without extension from npm packages' , ( ) => (
43+ func ( '@import "foundation/scss/foundation/_variables"' )
44+ ) ) ;
45+ it ( 'should resolve Sass @import for partials without underscore from npm packages' , ( ) => (
46+ func ( '@import "foundation/scss/foundation/variables.scss"' )
47+ ) ) ;
48+ it ( 'should resolve Sass @import for partials without underscore and extension from npm packages' , ( ) => (
49+ func ( '@import "foundation/scss/foundation/variables"' )
50+ ) ) ;
51+ } ) ;
3952 } ) ;
4053} ) ;
0 commit comments