Tests/Unit/Module.Tests.ps1
|
BeforeAll { $moduleRoot = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path $manifestPath = Join-Path $moduleRoot 'psSIA.psd1' Import-Module $manifestPath -Force } Describe 'Module manifest' { It 'passes Test-ModuleManifest' { { Test-ModuleManifest -Path $manifestPath -ErrorAction Stop } | Should -Not -Throw } It 'exports exactly the functions declared in the manifest' { $manifest = Import-PowerShellDataFile -Path $manifestPath $exported = (Get-Command -Module psSIA).Name Compare-Object -ReferenceObject $manifest.FunctionsToExport -DifferenceObject $exported | Should -BeNullOrEmpty } It 'does not export any private helper function' { $publicNames = (Get-ChildItem -Path (Join-Path $moduleRoot 'Public') -Filter '*.ps1' -Recurse).BaseName $privateNames = (Get-ChildItem -Path (Join-Path $moduleRoot 'Private') -Filter '*.ps1').BaseName $exported = (Get-Command -Module psSIA).Name foreach ($name in $privateNames) { $exported | Should -Not -Contain $name } $publicNames | Should -Not -BeNullOrEmpty } It 'documents every exported command with comment-based help' { foreach ($name in (Get-Command -Module psSIA).Name) { $help = Get-Help -Name $name -Full $help.Synopsis | Should -Not -BeNullOrEmpty -Because "$name should have a .SYNOPSIS" $help.description | Should -Not -BeNullOrEmpty -Because "$name should have a .DESCRIPTION" } } } |