@@ -283,7 +283,7 @@ runInEachFileSystem(() => {
283283 beforeEach ( ( ) => fs = getFileSystem ( ) ) ;
284284
285285 describe ( 'loadSecondaryEntryPointInfoForApfV14()' , ( ) => {
286- it ( 'should return `null` of the primary `package.json` failed to be loaded' , ( ) => {
286+ it ( 'should return `null` if the primary `package.json` failed to be loaded' , ( ) => {
287287 expect ( loadSecondaryEntryPointInfoForApfV14 ( fs , null , _abs ( '/foo' ) , _abs ( '/foo/bar' ) ) )
288288 . toBe ( null ) ;
289289 } ) ;
@@ -300,12 +300,39 @@ runInEachFileSystem(() => {
300300 . toBe ( null ) ;
301301 } ) ;
302302
303+ it ( 'should return `null` if the primary `package.json`\'s `exports` property is a string' ,
304+ ( ) => {
305+ const primaryPackageJson = {
306+ name : 'some-package' ,
307+ exports : './index.js' ,
308+ } ;
309+
310+ expect ( loadSecondaryEntryPointInfoForApfV14 (
311+ fs , primaryPackageJson , _abs ( '/foo' ) , _abs ( '/foo/bar' ) ) )
312+ . toBe ( null ) ;
313+ } ) ;
314+
315+ it ( 'should return `null` if the primary `package.json`\'s `exports` property is a string array' ,
316+ ( ) => {
317+ const primaryPackageJson = {
318+ name : 'some-package' ,
319+ exports : [
320+ './foo.js' ,
321+ './bar.js' ,
322+ ] ,
323+ } ;
324+
325+ expect ( loadSecondaryEntryPointInfoForApfV14 (
326+ fs , primaryPackageJson , _abs ( '/foo' ) , _abs ( '/foo/bar' ) ) )
327+ . toBe ( null ) ;
328+ } ) ;
329+
303330 it ( 'should return `null` if there is no info for the specified entry-point' , ( ) => {
304331 const primaryPackageJson = {
305332 name : 'some-package' ,
306333 exports : {
307334 './baz' : {
308- isBar : false ,
335+ main : './baz/index.js' ,
309336 } ,
310337 } ,
311338 } ;
@@ -315,19 +342,48 @@ runInEachFileSystem(() => {
315342 . toBe ( null ) ;
316343 } ) ;
317344
318- it ( 'should return the entry-point info if it exists' , ( ) => {
345+ it ( 'should return `null` if the entry-point info is a string' , ( ) => {
346+ const primaryPackageJson = {
347+ name : 'some-package' ,
348+ exports : {
349+ './bar' : './bar/index.js' ,
350+ } ,
351+ } ;
352+
353+ expect ( loadSecondaryEntryPointInfoForApfV14 (
354+ fs , primaryPackageJson , _abs ( '/foo' ) , _abs ( '/foo/bar' ) ) )
355+ . toBe ( null ) ;
356+ } ) ;
357+
358+ it ( 'should return `null` if the entry-point info is a string array' , ( ) => {
359+ const primaryPackageJson = {
360+ name : 'some-package' ,
361+ exports : {
362+ './bar' : [
363+ './bar/a.js' ,
364+ './bar/b.js' ,
365+ ] ,
366+ } ,
367+ } ;
368+
369+ expect ( loadSecondaryEntryPointInfoForApfV14 (
370+ fs , primaryPackageJson , _abs ( '/foo' ) , _abs ( '/foo/bar' ) ) )
371+ . toBe ( null ) ;
372+ } ) ;
373+
374+ it ( 'should return the entry-point info if it exists and is an object' , ( ) => {
319375 const primaryPackageJson = {
320376 name : 'some-package' ,
321377 exports : {
322378 './bar' : {
323- isBar : true ,
379+ main : './bar/index.js' ,
324380 } ,
325381 } ,
326382 } ;
327383
328384 expect ( loadSecondaryEntryPointInfoForApfV14 (
329385 fs , primaryPackageJson , _abs ( '/foo' ) , _abs ( '/foo/bar' ) ) )
330- . toEqual ( { isBar : true } ) ;
386+ . toEqual ( { main : './bar/index.js' } ) ;
331387 } ) ;
332388 } ) ;
333389} ) ;
0 commit comments