@@ -95,7 +95,7 @@ testFSImporter("FilesystemImporter", defaultImporter);
95
95
testFSImporter ( "Default PathAliasImporter" , new NodeJsImporter ( { } ) ) ;
96
96
testFSImporter ( "Configured PathAliasImporter" , new NodeJsImporter ( { alias : ALIAS_FIXTURES } ) ) ;
97
97
98
- describe ( "Node Module Importer" , ( ) => {
98
+ describe ( "Node Module Importer – Fully Qualified Paths " , ( ) => {
99
99
before ( function ( this : IHookCallbackContext ) {
100
100
this . importer = new NodeJsImporter ( ) ;
101
101
this . config = getConfiguration ( NODE_MODULE_FIXTURES ) ;
@@ -123,6 +123,41 @@ describe("Node Module Importer", () => {
123
123
} ) ;
124
124
} ) ;
125
125
126
+ describe ( "Node Module Importer – Package Names" , ( ) => {
127
+ before ( function ( this : IHookCallbackContext ) {
128
+ this . importer = new NodeJsImporter ( ) ;
129
+ this . config = getConfiguration ( NODE_MODULE_FIXTURES ) ;
130
+ } ) ;
131
+ it ( "handles un-scoped packages default package export" , function ( ) {
132
+ let packageName = "package" ;
133
+ let ident = this . importer . identifier ( null , packageName , this . config ) ;
134
+ let resolvedFilename = this . importer . filesystemPath ( ident , this . config ) ;
135
+ assert . equal ( ident , path . join ( NODE_MODULE_FIXTURES , "node_modules" , packageName , "blocks" , "index.block.css" ) ) ;
136
+ assert . equal ( resolvedFilename , path . join ( NODE_MODULE_FIXTURES , "node_modules" , packageName , "blocks" , "index.block.css" ) ) ;
137
+ } ) ;
138
+ it ( "handles scoped packages default package export" , function ( ) {
139
+ let packageName = "@scoped/package" ;
140
+ let ident = this . importer . identifier ( null , packageName , this . config ) ;
141
+ let resolvedFilename = this . importer . filesystemPath ( ident , this . config ) ;
142
+ assert . equal ( ident , path . join ( NODE_MODULE_FIXTURES , "node_modules" , packageName , "blocks" , "index.block.css" ) ) ;
143
+ assert . equal ( resolvedFilename , path . join ( NODE_MODULE_FIXTURES , "node_modules" , packageName , "blocks" , "index.block.css" ) ) ;
144
+ } ) ;
145
+ it ( "handles packages with a custom main block export" , function ( ) {
146
+ let packageName = "@scoped/custom-main" ;
147
+ let ident = this . importer . identifier ( null , packageName , this . config ) ;
148
+ let resolvedFilename = this . importer . filesystemPath ( ident , this . config ) ;
149
+ assert . equal ( ident , path . join ( NODE_MODULE_FIXTURES , "node_modules" , packageName , "blocks" , "custom.block.css" ) ) ;
150
+ assert . equal ( resolvedFilename , path . join ( NODE_MODULE_FIXTURES , "node_modules" , packageName , "blocks" , "custom.block.css" ) ) ;
151
+ } ) ;
152
+ it ( "gracefully degrades back to relative lookup for undiscoverable modules. Is never found without extension." , function ( ) {
153
+ let packageName = "@scoped/non-existent" ;
154
+ let ident = this . importer . identifier ( null , packageName , this . config ) ;
155
+ let resolvedFilename = this . importer . filesystemPath ( ident , this . config ) ;
156
+ assert . equal ( ident , path . join ( NODE_MODULE_FIXTURES , packageName ) ) ;
157
+ assert . equal ( resolvedFilename , null ) ;
158
+ } ) ;
159
+ } ) ;
160
+
126
161
describe ( "PathAliasImporter" , ( ) => {
127
162
before ( function ( this : IHookCallbackContext ) {
128
163
let aliases = {
0 commit comments