resources/templates/NewScript/parts/Script.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
Describe 'Test <%=$PLASTER_PARAM_ScriptName%>' {
    BeforeAll {
        $ModuleHome = <%=$PLASTER_ModuleHomeDeclarationCode%>

        # Reimports '<%=$PLASTER_ModuleName%>'. If its not currently import just silently continue
        Remove-Module -Name '<%=$PLASTER_ModuleName%>' -ErrorAction SilentlyContinue
        Import-Module $ModuleHome

        InModuleScope '<%=$PLASTER_ModuleName%>' {
            $script:SUT = $true
        }
    }
    
    AfterAll {
        InModuleScope '<%=$PLASTER_ModuleName%>' {
            $script:SUT = $false
        }
    }

    Context 'Post executing New-Script' {
        It 'Should have command accessible' {
            $Results = Get-Command <%=$PLASTER_PARAM_ScriptName%> | Select-Object -ExpandProperty CommandType
            $Results | Should -Be 'Function'
        }
    }
}