refactor(tests): streamline test cases

This commit is contained in:
Jeffrey
2026-10-25 21:29:44 +01:00
parent 74648cbe26
commit 72ab1f348c
14 changed files with 75 additions and 94 deletions
+2 -2
View File
@@ -34,6 +34,7 @@ Describe 'Disable-TelemetryScheduledTasks' {
}
Mock Invoke-NonBlocking { @{ Success = $true; Status = 'Disabled' } }
Mock Write-Host {}
Mock Write-Warning {}
}
It 'dispatches every task to the non-blocking scheduler' {
@@ -175,7 +176,6 @@ Describe 'Disable-TelemetryScheduledTasks' {
It 'returns false for an unknown scheduler result' {
Mock Get-TelemetryScheduledTasks { @(@{ Path = '\Microsoft\Windows\Test\'; Name = 'Telemetry' }) }
Mock Invoke-NonBlocking { $null }
Mock Write-Warning {}
Disable-TelemetryScheduledTasks | Should -BeFalse
Should -Invoke Write-Warning -Times 1 -Exactly
@@ -194,6 +194,7 @@ Describe 'Enable-TelemetryScheduledTasks' {
}
Mock Invoke-NonBlocking { @{ Success = $true; Status = 'Enabled' } }
Mock Write-Host {}
Mock Write-Warning {}
}
It 'dispatches every task to the non-blocking scheduler' {
@@ -305,7 +306,6 @@ Describe 'Enable-TelemetryScheduledTasks' {
It 'returns false when the scheduler throws' {
Mock Get-TelemetryScheduledTasks { @(@{ Path = '\Microsoft\Windows\Test\'; Name = 'Telemetry' }) }
Mock Invoke-NonBlocking { throw 'scheduler unavailable' }
Mock Write-Warning {}
Enable-TelemetryScheduledTasks | Should -BeFalse
Should -Invoke Write-Warning -Times 1 -Exactly -ParameterFilter { $Message -match 'scheduler unavailable' }