Tests/Unit/Search-History.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 'Search-History (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 'Search-History').Count | Should -Be 1 } It 'has CmdletBinding' { $cmd = Get-Command 'Search-History' $cmd.CmdletBinding | Should -Be $true } It 'declares the -Pattern parameter' { $cmd = Get-Command 'Search-History' $cmd.Parameters.ContainsKey('Pattern') | Should -Be $true } It '-Pattern is mandatory' { $cmd = Get-Command 'Search-History' $attrs = $cmd.Parameters['Pattern'].Attributes $paramAttr = $attrs | Where-Object { $_.GetType().Name -eq 'ParameterAttribute' } | Select-Object -First 1 $paramAttr.Mandatory | Should -Be $true } It 'declares the -Count parameter' { $cmd = Get-Command 'Search-History' $cmd.Parameters.ContainsKey('Count') | Should -Be $true } It 'declares the -Patch parameter' { $cmd = Get-Command 'Search-History' $cmd.Parameters.ContainsKey('Patch') | Should -Be $true } It '-Patch is a switch parameter' { $cmd = Get-Command 'Search-History' $cmd.Parameters['Patch'].ParameterType.Name | Should -Be 'SwitchParameter' } It 'has a non-empty .SYNOPSIS' { $help = Get-Help 'Search-History' -ErrorAction SilentlyContinue $help.Synopsis | Should -Not -BeNullOrEmpty } It 'has at least one .EXAMPLE in CBH' { $help = Get-Help 'Search-History' -Full -ErrorAction SilentlyContinue @($help.examples.example).Count -gt 0 | Should -Be $true } } |