@@ -4,30 +4,32 @@ import dependencyTree from '../index.js';
44import { fixtures } from './helpers.js' ;
55
66describe ( 'package-specific node_modules resolution' , ( ) => {
7- const directory = fixtures ( 'es6' , 'parentChild' ) ;
8- const filename = path . normalize ( `${ directory } /module.entry.js` ) ;
9- const rootChildPath = path . normalize ( `${ directory } /node_modules/child_node_module/index.main.js` ) ;
10- const nestedChildPath = path . normalize ( `${ directory } /node_modules/parent_module_a/node_modules/child_node_module/index.main.js` ) ;
11-
12- it ( 'finds sub package in node module package' , ( ) => {
13- const treeList = dependencyTree ( {
14- filename,
15- directory,
16- isListForm : true
7+ describe ( 'with a nested parent/child package layout' , ( ) => {
8+ const directory = fixtures ( 'es6' , 'parentChild' ) ;
9+ const filename = path . normalize ( `${ directory } /module.entry.js` ) ;
10+ const rootChildPath = path . normalize ( `${ directory } /node_modules/child_node_module/index.main.js` ) ;
11+ const nestedChildPath = path . normalize ( `${ directory } /node_modules/parent_module_a/node_modules/child_node_module/index.main.js` ) ;
12+
13+ it ( 'finds sub package in node module package' , ( ) => {
14+ const treeList = dependencyTree ( {
15+ filename,
16+ directory,
17+ isListForm : true
18+ } ) ;
19+
20+ expect ( treeList ) . toContain ( nestedChildPath ) ;
1721 } ) ;
1822
19- expect ( treeList ) . toContain ( nestedChildPath ) ;
20- } ) ;
23+ it ( 'uses correct version of sub package in node module package' , ( ) => {
24+ const treeList = dependencyTree ( {
25+ filename,
26+ directory,
27+ isListForm : true
28+ } ) ;
2129
22- it ( 'uses correct version of sub package in node module package' , ( ) => {
23- const treeList = dependencyTree ( {
24- filename,
25- directory,
26- isListForm : true
30+ expect ( treeList ) . not . toContain ( rootChildPath ) ;
31+ expect ( treeList ) . toContain ( nestedChildPath ) ;
2732 } ) ;
28-
29- expect ( treeList ) . not . toContain ( rootChildPath ) ;
30- expect ( treeList ) . toContain ( nestedChildPath ) ;
3133 } ) ;
3234
3335 it ( 'falls back to entry directory when a node_modules file has no package subpath' , ( ) => {
0 commit comments