@@ -14,46 +14,48 @@ const pipelines = {
14
14
'cssi' : [ ]
15
15
}
16
16
17
- Object . keys ( pipelines ) . forEach ( dirname => {
18
- describe ( dirname , ( ) => {
19
- let testDir = path . join ( __dirname , dirname )
20
-
21
- fs . readdirSync ( testDir ) . forEach ( testCase => {
22
- if ( fs . existsSync ( path . join ( testDir , testCase , 'source.css' ) ) ) {
23
- it ( 'should ' + testCase . replace ( / - / g, ' ' ) , done => {
24
- let expected = normalize ( fs . readFileSync ( path . join ( testDir , testCase , 'expected.css' ) , 'utf-8' ) )
25
- let loader = new FileSystemLoader ( testDir , pipelines [ dirname ] )
26
- let expectedTokens = JSON . parse ( fs . readFileSync ( path . join ( testDir , testCase , 'expected.json' ) , 'utf-8' ) )
27
-
28
- loader . fetch ( `${ testCase } /source.css` , '/' ) . then ( tokens => {
17
+ describe ( 'css-modules-loader-core' , function ( ) {
18
+ Object . keys ( pipelines ) . forEach ( dirname => {
19
+ describe ( dirname , ( ) => {
20
+ let testDir = path . join ( __dirname , dirname )
21
+
22
+ fs . readdirSync ( testDir ) . forEach ( testCase => {
23
+ if ( fs . existsSync ( path . join ( testDir , testCase , 'source.css' ) ) ) {
24
+ it ( 'should ' + testCase . replace ( / - / g, ' ' ) , done => {
25
+ let expected = normalize ( fs . readFileSync ( path . join ( testDir , testCase , 'expected.css' ) , 'utf-8' ) )
26
+ let loader = new FileSystemLoader ( testDir , pipelines [ dirname ] )
27
+ let expectedTokens = JSON . parse ( fs . readFileSync ( path . join ( testDir , testCase , 'expected.json' ) , 'utf-8' ) )
28
+
29
+ loader . fetch ( `${ testCase } /source.css` , '/' ) . then ( tokens => {
30
+ assert . equal ( loader . finalSource , expected )
31
+ assert . equal ( JSON . stringify ( tokens ) , JSON . stringify ( expectedTokens ) )
32
+ } ) . then ( done , done )
33
+ } ) ;
34
+ }
35
+ } ) ;
36
+ } ) ;
37
+ } )
38
+
39
+ // special case for testing multiple sources
40
+ describe ( 'multiple sources' , ( ) => {
41
+ let testDir = path . join ( __dirname , 'test-cases' )
42
+ let testCase = 'multiple-sources' ;
43
+ let dirname = 'test-cases' ;
44
+
45
+ if ( fs . existsSync ( path . join ( testDir , testCase , 'source1.css' ) ) ) {
46
+ it ( 'should ' + testCase . replace ( / - / g, ' ' ) , done => {
47
+ let expected = normalize ( fs . readFileSync ( path . join ( testDir , testCase , 'expected.css' ) , 'utf-8' ) )
48
+ let loader = new FileSystemLoader ( testDir , pipelines [ dirname ] )
49
+ let expectedTokens = JSON . parse ( fs . readFileSync ( path . join ( testDir , testCase , 'expected.json' ) , 'utf-8' ) )
50
+
51
+ loader . fetch ( `${ testCase } /source1.css` , '/' ) . then ( tokens1 => {
52
+ loader . fetch ( `${ testCase } /source2.css` , '/' ) . then ( tokens2 => {
29
53
assert . equal ( loader . finalSource , expected )
54
+ const tokens = Object . assign ( { } , tokens1 , tokens2 ) ;
30
55
assert . equal ( JSON . stringify ( tokens ) , JSON . stringify ( expectedTokens ) )
31
56
} ) . then ( done , done )
32
- } ) ;
33
- }
34
- } ) ;
57
+ } )
58
+ } ) ;
59
+ }
35
60
} ) ;
36
- } )
37
-
38
- // special case for testing multiple sources
39
- describe ( 'multiple sources' , ( ) => {
40
- let testDir = path . join ( __dirname , 'test-cases' )
41
- let testCase = 'multiple-sources' ;
42
- let dirname = 'test-cases' ;
43
-
44
- if ( fs . existsSync ( path . join ( testDir , testCase , 'source1.css' ) ) ) {
45
- it ( 'should ' + testCase . replace ( / - / g, ' ' ) , done => {
46
- let expected = normalize ( fs . readFileSync ( path . join ( testDir , testCase , 'expected.css' ) , 'utf-8' ) )
47
- let loader = new FileSystemLoader ( testDir , pipelines [ dirname ] )
48
- let expectedTokens = JSON . parse ( fs . readFileSync ( path . join ( testDir , testCase , 'expected.json' ) , 'utf-8' ) )
49
-
50
- loader . fetch ( `${ testCase } /source1.css` , '/' ) . then ( tokens1 => {
51
- loader . fetch ( `${ testCase } /source2.css` , '/' ) . then ( tokens2 => {
52
- assert . equal ( loader . finalSource , expected )
53
- const tokens = Object . assign ( { } , tokens1 , tokens2 ) ;
54
- assert . equal ( JSON . stringify ( tokens ) , JSON . stringify ( expectedTokens ) )
55
- } ) . then ( done , done )
56
- } )
57
- } ) ;
58
- }
59
- } ) ;
61
+ } ) ;
0 commit comments