@@ -341,6 +341,40 @@ describe("install.ps1 failure handling", () => {
341341 "" ,
342342 ] . join ( "\n" ) ,
343343 } ,
344+ {
345+ name : "winget-stale-node-registration" ,
346+ source : [
347+ scriptWithoutEntryPoint ,
348+ "" ,
349+ "function Get-Command {" ,
350+ " [CmdletBinding()]" ,
351+ " param([string]$Name)" ,
352+ " if ($Name -eq 'winget') { return $true }" ,
353+ " return $null" ,
354+ "}" ,
355+ "filter Out-Host { }" ,
356+ "function Refresh-ProcessPath { }" ,
357+ "function Add-InstalledNodeToProcessPath { return $false }" ,
358+ "$script:wingetCalls = @()" ,
359+ "function winget {" ,
360+ " $script:wingetCalls += ($args -join ' ')" ,
361+ " if ($script:wingetCalls.Count -eq 1) {" ,
362+ " $global:LASTEXITCODE = -1978335189" ,
363+ " } else {" ,
364+ " $global:LASTEXITCODE = 0" ,
365+ " }" ,
366+ " Write-Output 'winget output'" ,
367+ "}" ,
368+ "function Check-Node { return ($script:wingetCalls.Count -ge 2) }" ,
369+ "$result = @(Install-Node)" ,
370+ 'if ($result.Count -ne 1 -or $result[0] -ne $true) { throw "Install-Node returned $result" }' ,
371+ "if ($script:wingetCalls.Count -ne 2) { throw \"Calls=$($script:wingetCalls -join '|')\" }" ,
372+ "if ($script:wingetCalls[1] -ne 'install OpenJS.NodeJS.LTS --source winget --force --accept-package-agreements --accept-source-agreements') {" ,
373+ ' throw "ForceCall=$($script:wingetCalls[1])"' ,
374+ "}" ,
375+ "" ,
376+ ] . join ( "\n" ) ,
377+ } ,
344378 {
345379 name : "chocolatey-node-upgrade" ,
346380 source : [
@@ -601,6 +635,7 @@ describe("install.ps1 failure handling", () => {
601635
602636 runIfPowerShell ( "upgrades and validates Node installed by Windows package managers" , ( ) => {
603637 expectBatchedPowerShellCase ( "winget-node-delayed-path" ) ;
638+ expectBatchedPowerShellCase ( "winget-stale-node-registration" ) ;
604639 expectBatchedPowerShellCase ( "chocolatey-node-upgrade" ) ;
605640 expectBatchedPowerShellCase ( "scoop-node-update" ) ;
606641 expectBatchedPowerShellCase ( "package-manager-node-validation-failure" ) ;
0 commit comments