|
| 1 | +Describe 'Build-PSBuildMAMLHelp' { |
| 2 | + BeforeAll { |
| 3 | + $script:moduleName = 'PowerShellBuild' |
| 4 | + $script:moduleRoot = Split-Path -Path $PSScriptRoot -Parent |
| 5 | + Import-Module ([IO.Path]::Combine($script:moduleRoot, 'Output', $script:moduleName)) -Force |
| 6 | + } |
| 7 | + |
| 8 | + It 'Generates help for each locale directory under Path' { |
| 9 | + Mock Get-ChildItem { |
| 10 | + @( |
| 11 | + [PSCustomObject]@{ Name = 'en-US' } |
| 12 | + [PSCustomObject]@{ Name = 'fr-FR' } |
| 13 | + ) |
| 14 | + } -ParameterFilter { $Path -eq 'docs/help' -and $Directory } |
| 15 | + |
| 16 | + Mock New-ExternalHelp {} |
| 17 | + |
| 18 | + Build-PSBuildMAMLHelp -Path 'docs/help' -DestinationPath 'out/module' -Verbose:$false |
| 19 | + |
| 20 | + Assert-MockCalled New-ExternalHelp -Times 2 -Exactly |
| 21 | + Assert-MockCalled New-ExternalHelp -Times 1 -Exactly -ParameterFilter { |
| 22 | + $Path -eq [IO.Path]::Combine('docs/help', 'en-US') -and |
| 23 | + $OutputPath -eq [IO.Path]::Combine('out/module', 'en-US') -and |
| 24 | + $Force -eq $true -and |
| 25 | + $ErrorAction -eq 'SilentlyContinue' |
| 26 | + } |
| 27 | + Assert-MockCalled New-ExternalHelp -Times 1 -Exactly -ParameterFilter { |
| 28 | + $Path -eq [IO.Path]::Combine('docs/help', 'fr-FR') -and |
| 29 | + $OutputPath -eq [IO.Path]::Combine('out/module', 'fr-FR') -and |
| 30 | + $Force -eq $true -and |
| 31 | + $ErrorAction -eq 'SilentlyContinue' |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + It 'Surfaces errors from New-ExternalHelp (platyPS dependency)' { |
| 36 | + Mock Get-ChildItem { |
| 37 | + @([PSCustomObject]@{ Name = 'en-US' }) |
| 38 | + } -ParameterFilter { $Path -eq 'docs/help' -and $Directory } |
| 39 | + |
| 40 | + Mock New-ExternalHelp { |
| 41 | + throw 'The term New-ExternalHelp is not recognized as the name of a cmdlet.' |
| 42 | + } |
| 43 | + |
| 44 | + { |
| 45 | + Build-PSBuildMAMLHelp -Path 'docs/help' -DestinationPath 'out/module' -Verbose:$false |
| 46 | + } | Should -Throw '*New-ExternalHelp*' |
| 47 | + } |
| 48 | +} |
0 commit comments