mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2026-08-23 16:12:08 +00:00
Add comprehensive test suite, fix minor issues, rename function and file names to match approved verbs (#708)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
BeforeAll {
|
||||
function Show-MessageBox { param($Message, $Title, $Button, $Icon, $Owner) 'Yes' }
|
||||
. (Join-Path $PSScriptRoot '..\Scripts\Helpers\Confirm-UnsafeAppRemoval.ps1')
|
||||
}
|
||||
|
||||
Describe 'Confirm-UnsafeAppRemoval' {
|
||||
BeforeEach {
|
||||
$global:Silent = $false
|
||||
Mock Show-MessageBox { 'Yes' }
|
||||
}
|
||||
|
||||
AfterEach { Remove-Variable -Name Silent -Scope Global -ErrorAction SilentlyContinue }
|
||||
|
||||
It 'returns true without prompting for ordinary applications' {
|
||||
Confirm-UnsafeAppRemoval -SelectedApps @('Contoso.App') | Should -BeTrue
|
||||
Should -Invoke Show-MessageBox -Times 0 -Exactly
|
||||
}
|
||||
|
||||
It 'skips all prompts in silent mode' {
|
||||
$global:Silent = $true
|
||||
|
||||
Confirm-UnsafeAppRemoval -SelectedApps @('Microsoft.WindowsStore', 'Microsoft.WindowsTerminal') | Should -BeTrue
|
||||
Should -Invoke Show-MessageBox -Times 0 -Exactly
|
||||
}
|
||||
|
||||
It 'stops when Microsoft Store removal is declined' {
|
||||
Mock Show-MessageBox { 'No' }
|
||||
|
||||
Confirm-UnsafeAppRemoval -SelectedApps @('Microsoft.WindowsStore', 'Microsoft.WindowsTerminal') | Should -BeFalse
|
||||
Should -Invoke Show-MessageBox -Times 1 -Exactly
|
||||
}
|
||||
|
||||
It 'requires confirmation for both dangerous applications' {
|
||||
Confirm-UnsafeAppRemoval -SelectedApps @('Microsoft.WindowsStore', 'Microsoft.WindowsTerminal') | Should -BeTrue
|
||||
Should -Invoke Show-MessageBox -Times 2 -Exactly
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user