tests/Unit/Public/Enable-ChocolateyFeature.tests.ps1

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
InModuleScope Chocolatey {
    Describe Enable-ChocolateyFeature {

        Mock Get-Command -MockWith { Get-Command Write-Output } -ParameterFilter {$Name -eq 'choco.exe'}
        Mock Get-ChocolateyFeature -MockWith {
            'MyChocoFeature'
        }
        Mock Get-ChocolateyDefaultArgument -MockWith { 'TestArgument' }
        
        Context 'Default' {

            It 'Should call Get-Command' {
                $null = Enable-ChocolateyFeature -Name 'TestFeature'
                {Assert-MockCalled Get-Command} | Should not Throw
            }

            It 'Should call Get-ChocolateyFeature' {
                $null = Enable-ChocolateyFeature -Name 'TestFeature'
                {Assert-MockCalled Get-ChocolateyFeature} | Should not Throw
            }
            
            It 'Should not return value' {
                $return = Enable-ChocolateyFeature -Name 'TestFeature'
                $return | Should BeNullOrEmpty
            }
        }
    }
}