mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-08-21 23:26:42 +00:00
22 lines
959 B
PowerShell
22 lines
959 B
PowerShell
Describe 'Wait-ForKeyPress' {
|
|
It 'exits cleanly without prompting when Silent is enabled' {
|
|
$scriptPath = Join-Path $PSScriptRoot '..\Scripts\CLI\Wait-ForKeyPress.ps1'
|
|
$command = "function Stop-Transcript {}; `$global:Silent = `$true; . '$scriptPath'; Wait-ForKeyPress"
|
|
$encodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command))
|
|
|
|
& powershell.exe -NoProfile -EncodedCommand $encodedCommand
|
|
|
|
$LASTEXITCODE | Should -Be 0
|
|
}
|
|
|
|
It 'uses the requested exit code' {
|
|
$scriptPath = Join-Path $PSScriptRoot '..\Scripts\CLI\Wait-ForKeyPress.ps1'
|
|
$command = "function Stop-Transcript {}; `$global:Silent = `$true; . '$scriptPath'; Wait-ForKeyPress -ExitCode 1"
|
|
$encodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command))
|
|
|
|
& powershell.exe -NoProfile -EncodedCommand $encodedCommand
|
|
|
|
$LASTEXITCODE | Should -Be 1
|
|
}
|
|
}
|