Skip to content

Commit

Permalink
Refactor PSDocs.Common.Tests.ps1 to import PSDocs module and use curr…
Browse files Browse the repository at this point in the history
…ent encoding variable in test names
  • Loading branch information
vicperdana committed Aug 21, 2024
1 parent 9797439 commit 21920a7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/PSDocs.Tests/PSDocs.Common.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,13 @@ Describe 'Get-PSDocument' -Tag 'Cmdlet', 'Common', 'Get-PSDocument' {
$testModuleSourcePath = Join-Path $here -ChildPath 'TestModule';
Mock -CommandName 'LoadModule' -ModuleName 'PSDocs' -Verifiable;
Import-Module $testModuleSourcePath -Force;
Import-Module PSDocs -Force;
$rootPath = $PWD;
Import-Module (Join-Path -Path $rootPath.Path -ChildPath out/modules/PSDocs) -Force;
$result = @(Get-PSDocument -Module 'TestModule');
$currentLoadingPreference = Get-Variable -Name PSModuleAutoLoadingPreference -ErrorAction SilentlyContinue -ValueOnly
if (-not (Get-Module -Name PSDocs -ListAvailable)) {
Throw "PSDocs module is not available on this system."
}
}
It 'Returns documents' {
$result = @(Get-PSDocument -Module 'TestModule');
Expand All @@ -252,6 +256,8 @@ Describe 'Get-PSDocument' -Tag 'Cmdlet', 'Common', 'Get-PSDocument' {

InModuleScope PSDocs {
It 'Loads module with preference' {
Mock -CommandName 'LoadModule' -ModuleName 'PSDocs'
$currentLoadingPreference = Get-Variable -Name PSModuleAutoLoadingPreference -ErrorAction SilentlyContinue -ValueOnly
try {
# Test negative case
$Global:PSModuleAutoLoadingPreference = [System.Management.Automation.PSModuleAutoLoadingPreference]::None
Expand Down

0 comments on commit 21920a7

Please sign in to comment.