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