Skip to content

Commit

Permalink
Refactor PSDocs.Common.Tests.ps1 to remove unnecessary module removal…
Browse files Browse the repository at this point in the history
… and use current encoding variable in test names
  • Loading branch information
vicperdana committed Aug 21, 2024
1 parent 92bfb0a commit c581fca
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/PSDocs.Tests/PSDocs.Common.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ Describe 'Get-PSDocument' -Tag 'Cmdlet', 'Common', 'Get-PSDocument' {
if (-not (Get-Module -Name PSDocs -ListAvailable)) {
Throw "PSDocs module is not available on this system."
}

if ($Null -ne (Get-Module -Name TestModule -ErrorAction SilentlyContinue)) {
$Null = Remove-Module -Name TestModule;
}
}
It 'Returns documents' {
$result = @(Get-PSDocument -Module 'TestModule');
Expand All @@ -248,13 +252,10 @@ Describe 'Get-PSDocument' -Tag 'Cmdlet', 'Common', 'Get-PSDocument' {
$result.Id | Should -BeIn 'TestModule\TestDocument1', 'TestModule\TestDocument2';
}

if ($Null -ne (Get-Module -Name TestModule -ErrorAction SilentlyContinue)) {
$Null = Remove-Module -Name TestModule;
}

InModuleScope PSDocs {
It 'Loads module with preference' {
Mock -CommandName 'LoadModule' -ModuleName 'PSDocs'
Mock -CommandName 'LoadModule' -ModuleName 'PSDocs' -Verifiable;
$currentLoadingPreference = Get-Variable -Name PSModuleAutoLoadingPreference -ErrorAction SilentlyContinue -ValueOnly
try {
# Test negative case
Expand Down

0 comments on commit c581fca

Please sign in to comment.