@@ -55,6 +55,24 @@ describe(`${getNotInstalledPackagesForPlatform.name}`, () => {
5555 architectures : [ 'architecture2' ] ,
5656 installPath : 'path3' ,
5757 } ,
58+ {
59+ description : 'neutral platform and architecture uninstalled package' ,
60+ platforms : [ 'neutral' ] ,
61+ architectures : [ 'neutral' ] ,
62+ installPath : 'path6' ,
63+ } ,
64+ {
65+ description : 'neutral platform but specific architecture package' ,
66+ platforms : [ 'neutral' ] ,
67+ architectures : [ 'architecture1' ] ,
68+ installPath : 'path7' ,
69+ } ,
70+ {
71+ description : 'specific platform but neutral architecture package' ,
72+ platforms : [ 'linux' ] ,
73+ architectures : [ 'neutral' ] ,
74+ installPath : 'path8' ,
75+ } ,
5876 ] ;
5977
6078 beforeEach ( async ( ) => {
@@ -79,18 +97,46 @@ describe(`${getNotInstalledPackagesForPlatform.name}`, () => {
7997 test ( 'Filters the packages based on Platform Information' , async ( ) => {
8098 const platformInfo = new PlatformInformation ( 'win32' , 'architecture2' ) ;
8199 const filteredPackages = await getNotInstalledPackagesForPlatform ( absolutePathPackages , platformInfo ) ;
82- expect ( filteredPackages . length ) . toEqual ( 1 ) ;
100+ expect ( filteredPackages . length ) . toEqual ( 2 ) ;
83101 expect ( filteredPackages [ 0 ] . description ) . toEqual ( 'win32-Architecture2 uninstalled package' ) ;
84102 expect ( filteredPackages [ 0 ] . platforms [ 0 ] ) . toEqual ( 'win32' ) ;
85103 expect ( filteredPackages [ 0 ] . architectures [ 0 ] ) . toEqual ( 'architecture2' ) ;
104+
105+ expect ( filteredPackages [ 1 ] . description ) . toEqual ( 'neutral platform and architecture uninstalled package' ) ;
106+ expect ( filteredPackages [ 1 ] . platforms [ 0 ] ) . toEqual ( 'neutral' ) ;
107+ expect ( filteredPackages [ 1 ] . architectures [ 0 ] ) . toEqual ( 'neutral' ) ;
86108 } ) ;
87109
88110 test ( 'Returns only the packages where install.Lock is not present' , async ( ) => {
89111 const platformInfo = new PlatformInformation ( 'linux' , 'architecture1' ) ;
90112 const filteredPackages = await getNotInstalledPackagesForPlatform ( absolutePathPackages , platformInfo ) ;
113+ // Should include linux-Architecture1 package + neutral package (both uninstalled)
114+ expect ( filteredPackages . length ) . toEqual ( 4 ) ;
115+
116+ const descriptions = filteredPackages . map ( ( pkg ) => pkg . description ) ;
117+ expect ( descriptions ) . toContain ( 'linux-Architecture1 uninstalled package' ) ;
118+ expect ( descriptions ) . toContain ( 'neutral platform and architecture uninstalled package' ) ;
119+ expect ( descriptions ) . toContain ( 'neutral platform but specific architecture package' ) ;
120+ expect ( descriptions ) . toContain ( 'specific platform but neutral architecture package' ) ;
121+ } ) ;
122+
123+ test ( 'Returns only neutral packages when no platform-specific packages match' , async ( ) => {
124+ const platformInfo = new PlatformInformation ( 'darwin' , 'arm64' ) ; // Non-existent platform/arch combo
125+ const filteredPackages = await getNotInstalledPackagesForPlatform ( absolutePathPackages , platformInfo ) ;
126+
127+ // Should only include neutral package (uninstalled one)
128+ expect ( filteredPackages . length ) . toEqual ( 1 ) ;
129+ expect ( filteredPackages [ 0 ] . description ) . toEqual ( 'neutral platform and architecture uninstalled package' ) ;
130+ expect ( filteredPackages [ 0 ] . platforms [ 0 ] ) . toEqual ( 'neutral' ) ;
131+ expect ( filteredPackages [ 0 ] . architectures [ 0 ] ) . toEqual ( 'neutral' ) ;
132+ } ) ;
133+
134+ test ( 'Filters out installed neutral packages' , async ( ) => {
135+ const platformInfo = new PlatformInformation ( 'darwin' , 'arm64' ) ; // Only neutral packages should match
136+ const filteredPackages = await getNotInstalledPackagesForPlatform ( absolutePathPackages , platformInfo ) ;
137+
138+ // Should only return uninstalled neutral package, not the installed one
91139 expect ( filteredPackages . length ) . toEqual ( 1 ) ;
92- expect ( filteredPackages [ 0 ] . description ) . toEqual ( 'linux-Architecture1 uninstalled package' ) ;
93- expect ( filteredPackages [ 0 ] . platforms [ 0 ] ) . toEqual ( 'linux' ) ;
94- expect ( filteredPackages [ 0 ] . architectures [ 0 ] ) . toEqual ( 'architecture1' ) ;
140+ expect ( filteredPackages [ 0 ] . description ) . toEqual ( 'neutral platform and architecture uninstalled package' ) ;
95141 } ) ;
96142} ) ;
0 commit comments