@@ -55,6 +55,24 @@ describe(`${getNotInstalledPackagesForPlatform.name}`, () => {
55
55
architectures : [ 'architecture2' ] ,
56
56
installPath : 'path3' ,
57
57
} ,
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
+ } ,
58
76
] ;
59
77
60
78
beforeEach ( async ( ) => {
@@ -79,18 +97,46 @@ describe(`${getNotInstalledPackagesForPlatform.name}`, () => {
79
97
test ( 'Filters the packages based on Platform Information' , async ( ) => {
80
98
const platformInfo = new PlatformInformation ( 'win32' , 'architecture2' ) ;
81
99
const filteredPackages = await getNotInstalledPackagesForPlatform ( absolutePathPackages , platformInfo ) ;
82
- expect ( filteredPackages . length ) . toEqual ( 1 ) ;
100
+ expect ( filteredPackages . length ) . toEqual ( 2 ) ;
83
101
expect ( filteredPackages [ 0 ] . description ) . toEqual ( 'win32-Architecture2 uninstalled package' ) ;
84
102
expect ( filteredPackages [ 0 ] . platforms [ 0 ] ) . toEqual ( 'win32' ) ;
85
103
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' ) ;
86
108
} ) ;
87
109
88
110
test ( 'Returns only the packages where install.Lock is not present' , async ( ) => {
89
111
const platformInfo = new PlatformInformation ( 'linux' , 'architecture1' ) ;
90
112
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
91
139
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' ) ;
95
141
} ) ;
96
142
} ) ;
0 commit comments