Skip to content

Commit

Permalink
Pester v5
Browse files Browse the repository at this point in the history
  • Loading branch information
tig committed Nov 4, 2023
1 parent 87300c4 commit 6208d22
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Source/F7History.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Tig Kindel
#
# Generated on: 11/3/2023
# Generated on: 11/4/2023
#

@{
Expand Down
63 changes: 31 additions & 32 deletions Tests/Public/f7_history.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
#requires -Module F7History

Describe "f7_history" {
Context "The f7_history function" {
$cmd = $null
try {
$cmd = get-item -path Function:\f7_history

} catch {
$cmd = $null
}
# Describe "f7_history" {
# Context "The f7_history function" {
# $cmd = $null
# try {
# $cmd = get-item -path Function:\f7_history
# } catch {
# $cmd = $null
# }

It "is defined" {
$cmd | Should -Be "f7_history"
}
}
# It " is defined" {
# $cmd | Should -Be "f7_history"
# }
# }

Context "The f7_history function" {
$parameters = (Get-Command f7_history).Parameters
It "has a required string parameter for the global flag" {
$parameters.ContainsKey("global") | Should -Be $true
$parameters["global"].ParameterType | Should -Be ([boolean])
$parameters["global"].Attributes.Where{$_ -is [Parameter]}.Mandatory | Should -Be $true
}
}
# Context "The f7_history function" {
# $parameters = (Get-Command f7_history).Parameters
# It "has a required string parameter for the global flag" {
# $parameters.ContainsKey("global") | Should -Be $true
# $parameters["global"].ParameterType | Should -Be ([boolean])
# $parameters["global"].Attributes.Where{$_ -is [Parameter]}.Mandatory | Should -Be $true
# }
# }

Context "Default key bindings" {
$Result = (Get-PSReadLineKeyHandler -Chord F7).Function
It "defines F7 as the default key binding" {
$Result | Should -Be "Show Matching Command History"
}
# Context "Default key bindings" {
# $Result = (Get-PSReadLineKeyHandler -Chord F7).Function
# It "defines F7 as the default key binding" {
# $Result | Should -Be "Show Matching Command History"
# }

$Result = (Get-PSReadLineKeyHandler -Chord Shift-F7).Function
It "defines Shift-F7 as the default key binding" {
$Result | Should -Be "Show Matching Command History for All"
}
}
}
# $Result = (Get-PSReadLineKeyHandler -Chord Shift-F7).Function
# It "defines Shift-F7 as the default key binding" {
# $Result | Should -Be "Show Matching Command History for All"
# }
# }
# }
10 changes: 5 additions & 5 deletions test.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#requires -Module PowerShellGet, @{ ModuleName = "Pester"; ModuleVersion = "4.10.1"; MaximumVersion = "4.999" }
# requires -Module PowerShellGet, @{ ModuleName = "Pester"; ModuleVersion = "5.5.0"; MaximumVersion = "5.0" }
using namespace Microsoft.PackageManagement.Provider.Utility
using namespace System.Management.Automation
param(
Expand Down Expand Up @@ -36,11 +36,11 @@ Write-Host "Invoke-Pester for Module $($ModuleUnderTest) version $($ModuleUnderT

if ($CodeCoverage) {
# Get code coverage for the psm1 file to a coverage.xml that we can mess with later
Invoke-Pester ./Tests -Show $Show -PesterOption @{
IncludeVSCodeMarker = $IncludeVSCodeMarker
} -CodeCoverage $ModuleUnderTest.Path -CodeCoverageOutputFile ./coverage.xml -PassThru | Convert-CodeCoverage -SourceRoot ./Source
# Invoke-Pester ./Tests -Show $Show -PesterOption @{
# IncludeVSCodeMarker = $IncludeVSCodeMarker
# } -CodeCoverage $ModuleUnderTest.Path -CodeCoverageOutputFile ./coverage.xml -PassThru | Convert-CodeCoverage -SourceRoot ./Source
} else {
Invoke-Pester ./Tests -Show $Show -PesterOption @{ IncludeVSCodeMarker = $IncludeVSCodeMarker }
Invoke-Pester -Path ./Tests
}

Write-Host
Expand Down

0 comments on commit 6208d22

Please sign in to comment.