Tests/Unit/Save-Work.Tests.ps1

# Generated by tools\Build-PublicUnitTests.ps1. Re-run to regenerate.
BeforeAll {

$ProjectRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
$ModulePath  = Join-Path $ProjectRoot 'GitEasy.psd1'
}

Describe 'Save-Work (unit contract)' {

    BeforeAll {
        Remove-Module GitEasy -Force -ErrorAction SilentlyContinue
        Import-Module $ModulePath -Force
    }

    It 'is exported by the GitEasy module' {
        @(Get-Command -Module GitEasy -Name 'Save-Work').Count | Should -Be 1
    }

    It 'has CmdletBinding' {
        $cmd = Get-Command 'Save-Work'
        $cmd.CmdletBinding | Should -Be $true
    }

    It 'supports ShouldProcess (-WhatIf and -Confirm available)' {
        $cmd = Get-Command 'Save-Work'
        $cmd.Parameters.ContainsKey('WhatIf')  | Should -Be $true
        $cmd.Parameters.ContainsKey('Confirm') | Should -Be $true
    }

    It 'declares the -Message parameter' {
        $cmd = Get-Command 'Save-Work'
        $cmd.Parameters.ContainsKey('Message') | Should -Be $true
    }

    It 'declares the -NoPush parameter' {
        $cmd = Get-Command 'Save-Work'
        $cmd.Parameters.ContainsKey('NoPush') | Should -Be $true
    }

    It '-NoPush is a switch parameter' {
        $cmd = Get-Command 'Save-Work'
        $cmd.Parameters['NoPush'].ParameterType.Name | Should -Be 'SwitchParameter'
    }

    It 'declares the -BumpVersion parameter' {
        $cmd = Get-Command 'Save-Work'
        $cmd.Parameters.ContainsKey('BumpVersion') | Should -Be $true
    }

    It '-BumpVersion is a switch parameter' {
        $cmd = Get-Command 'Save-Work'
        $cmd.Parameters['BumpVersion'].ParameterType.Name | Should -Be 'SwitchParameter'
    }

    It 'declares the -BumpKind parameter' {
        $cmd = Get-Command 'Save-Work'
        $cmd.Parameters.ContainsKey('BumpKind') | Should -Be $true
    }

    It '-BumpKind accepts only the documented values' {
        $cmd = Get-Command 'Save-Work'
        $set = ($cmd.Parameters['BumpKind'].Attributes | Where-Object { $_.GetType().Name -eq 'ValidateSetAttribute' } | Select-Object -First 1).ValidValues
        $set -contains 'Major' | Should -Be $true
        $set -contains 'Minor' | Should -Be $true
        $set -contains 'Build' | Should -Be $true
        $set -contains 'Revision' | Should -Be $true
    }

    It 'declares the -LogPath parameter' {
        $cmd = Get-Command 'Save-Work'
        $cmd.Parameters.ContainsKey('LogPath') | Should -Be $true
    }

    It 'has a non-empty .SYNOPSIS' {
        $help = Get-Help 'Save-Work' -ErrorAction SilentlyContinue
        $help.Synopsis | Should -Not -BeNullOrEmpty
    }

    It 'has at least one .EXAMPLE in CBH' {
        $help = Get-Help 'Save-Work' -Full -ErrorAction SilentlyContinue
        @($help.examples.example).Count -gt 0 | Should -Be $true
    }
}