@@ -17,6 +17,7 @@ import {
17
17
18
18
const FIXTURES = path . resolve ( __dirname , ".." , ".." , "test" , "fixtures" ) ;
19
19
const FSI_FIXTURES = path . join ( FIXTURES , "filesystemImporter" ) ;
20
+ const COMPILED_CSS_FIXTURES = path . join ( FIXTURES , "compiledFileImporting" ) ;
20
21
const ALIAS_FIXTURES = path . join ( FIXTURES , "pathAliasImporter" ) ;
21
22
const NODE_MODULE_FIXTURES = path . join ( FIXTURES , "nodeModuleImporter" ) ;
22
23
@@ -93,6 +94,60 @@ function testFSImporter(name: string, importer: Importer) {
93
94
assert . fail ( importedFile . type , "ImportedFile" , "Mismatched type given" ) ;
94
95
}
95
96
} ) ;
97
+ it ( "Can import Compiled CSS file with embedded definition data" , async ( ) => {
98
+ const EMBEDDED_DFN_FIXTURES = path . join ( COMPILED_CSS_FIXTURES , "embedded" ) ;
99
+ const options = getConfiguration ( EMBEDDED_DFN_FIXTURES ) ;
100
+ const ident = importer . identifier ( null , "nav.css" , options ) ;
101
+ const importedFile = await importer . import ( ident , options ) ;
102
+ if ( importedFile . type === "ImportedCompiledCssFile" ) {
103
+ assert . equal ( importedFile . identifier , ident ) ;
104
+ assert . equal ( importedFile . syntax , Syntax . css ) ;
105
+ assert . equal ( importedFile . blockId , "7d97e" ) ;
106
+ assert . deepEqual (
107
+ importedFile . cssContents . trim ( ) ,
108
+ fs . readFileSync (
109
+ path . join ( COMPILED_CSS_FIXTURES , "expectedResults" , "expectedCssContents.txt" ) ,
110
+ "utf-8" ,
111
+ ) . trim ( ) ,
112
+ ) ;
113
+ assert . deepEqual (
114
+ importedFile . definitionContents . trim ( ) ,
115
+ fs . readFileSync (
116
+ path . join ( COMPILED_CSS_FIXTURES , "expectedResults" , "expectedDfnContents.txt" ) ,
117
+ "utf-8" ,
118
+ ) . trim ( ) ,
119
+ ) ;
120
+ } else {
121
+ assert . fail ( importedFile . type , "ImportedCompiledCssFile" , "Mismatched type given" ) ;
122
+ }
123
+ } ) ;
124
+ it ( "Can import Compiled CSS file with external definition path" , async ( ) => {
125
+ const EXTERNAL_DFN_FIXTURES = path . join ( COMPILED_CSS_FIXTURES , "externaldef" ) ;
126
+ const options = getConfiguration ( EXTERNAL_DFN_FIXTURES ) ;
127
+ const ident = importer . identifier ( null , "nav.css" , options ) ;
128
+ const importedFile = await importer . import ( ident , options ) ;
129
+ if ( importedFile . type === "ImportedCompiledCssFile" ) {
130
+ assert . equal ( importedFile . identifier , ident ) ;
131
+ assert . equal ( importedFile . syntax , Syntax . css ) ;
132
+ assert . equal ( importedFile . blockId , "7d97e" ) ;
133
+ assert . deepEqual (
134
+ importedFile . cssContents . trim ( ) ,
135
+ fs . readFileSync (
136
+ path . join ( COMPILED_CSS_FIXTURES , "expectedResults" , "expectedCssContents.txt" ) ,
137
+ "utf-8" ,
138
+ ) . trim ( ) ,
139
+ ) ;
140
+ assert . deepEqual (
141
+ importedFile . definitionContents . trim ( ) ,
142
+ fs . readFileSync (
143
+ path . join ( COMPILED_CSS_FIXTURES , "expectedResults" , "expectedDfnContents.txt" ) ,
144
+ "utf-8" ,
145
+ ) . trim ( ) ,
146
+ ) ;
147
+ } else {
148
+ assert . fail ( importedFile . type , "ImportedCompiledCssFile" , "Mismatched type given" ) ;
149
+ }
150
+ } ) ;
96
151
} ) ;
97
152
}
98
153
0 commit comments