diff --git a/PowerShell/JumpCloud Module/Tests/Public/Users/Remove-JCUser.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Users/Remove-JCUser.Tests.ps1 index 1f102fbfc..44b48da6b 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/Remove-JCUser.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/Remove-JCUser.Tests.ps1 @@ -30,8 +30,7 @@ Describe -Tag:('JCUser') "Remove-JCUser 1.10" { } Describe -Tag:('JCUser') "Remove-JCUser 2.16.0" { BeforeAll { - # Mock Read-Host to auto answer 'Y' to the prompt - Mock -CommandName 'Read-Host' -MockWith { return 'Y' } + } It "Tests for CascadeManager param with Force" { $ManagerUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser @@ -55,7 +54,8 @@ Describe -Tag:('JCUser') "Remove-JCUser 2.16.0" { # The manager should be removed and the new manager should be set $RemoveUser.Results | Should -Be 'Deleted' # The new manager should be set to ManagerUser2 - { Get-JCUser -UserID $NewUser._id | Select-Object -ExpandProperty manager } | Should -Be $ManagerUser2._id + $manager = Get-JCUser -UserID $NewUser._id | Select-Object -ExpandProperty manager + $manager | Should -Be $ManagerUser2._id # Clean up Remove-JCUser -UserID $ManagerUser2._id -force Remove-JCUser -UserID $NewUser._id -force @@ -142,8 +142,7 @@ Describe -Tag:('JCUser') "Remove-JCUser 2.16.0" { # Set the manager for user Set-JCUser -UserID $ManagerUser._id -manager $ManagerUser2._id # ManagerUser2 is the manager of ManagerUser Set-JCUser -UserID $NewUser._id -manager $ManagerUser._id - Mock -CommandName 'Read-Host' -MockWith { return 'Y' } - Mock -CommandName 'Read-Host' -MockWith { return 'Y' } + Mock -CommandName 'Read-Host' -MockWith { return 'Y' } # Remove the manager and set the new manager $RemoveUser = Remove-JCUser -UserID $ManagerUser._id # Remove ManagerUser and should cascade to ManagerUser2. Prompts should be auto answered with 'Y'