Skip to content

Commit 2aa31d8

Browse files
authored
Merge pull request #27 from fflaten/fflaten-patch-1
Update advanced function test
2 parents aa784eb + 0e2993a commit 2aa31d8

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

Functions/Public/TimeStamp.ps1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ Function TimeStamp() {
4949
on this GitHub project at https://github.com/TechDufus/AdminToolkit
5050
#>
5151
Filter TimeStamp($color, $NoNewLine) {
52-
# [CmdletBinding()] # This is to pass the advanced function pester tests.
53-
# param () # This is to pass the advanced function pester tests.
54-
# Function # This is to pass the advanced function pester tests.
5552
if ($color -eq 'NoNewLine') {
5653
$color = 'White'
5754
$NoNewLine = 'NoNewLine'

Functions/Public/grep.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ If ($DetectedOS -eq 'Windows') {
3131
on this GitHub project at https://github.com/TechDufus/AdminToolkit
3232
#>
3333
Function grep() {
34-
# [CmdletBinding()] # This is to pass the advanced function pester tests.
3534
param(
3635
$regex
3736
)

Tests/Functions/Public/AdminToolkit_PublicFunctions_Universal.Tests.ps1

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ BeforeDiscovery {
2929

3030
Describe "Function: <_.BaseName>" -ForEach $PublicFunctions {
3131
BeforeDiscovery {
32-
$Parameters = ((Get-Command $_.BaseName -ErrorAction SilentlyContinue).Parameters).Keys
32+
$Command = Get-Command $_.BaseName -ErrorAction SilentlyContinue
33+
$Parameters = $Command.Parameters.Keys
3334
| Where-Object {
3435
$_ -notin ([System.Management.Automation.PSCmdlet]::CommonParameters) -and
3536
$_ -notin ([System.Management.Automation.PSCmdlet]::OptionalCommonParameters)
@@ -50,8 +51,8 @@ Describe "Function: <_.BaseName>" -ForEach $PublicFunctions {
5051
}
5152
}
5253

53-
It "Should register command with Get-Command" {
54-
(Get-Command $CurrentFunction.BaseName) | Should -BeOfType [System.Management.Automation.CommandInfo]
54+
It "Should register command with Get-Command" -ForEach @{ Command = $Command } {
55+
$Command | Should -BeOfType [System.Management.Automation.CommandInfo]
5556
}
5657
It "Should have comment-based help block" {
5758
$CurrentFunction.FullName | Should -FileContentMatch '<#'
@@ -69,10 +70,8 @@ Describe "Function: <_.BaseName>" -ForEach $PublicFunctions {
6970
It "Should have NOTES section in help" {
7071
$CurrentFunction.FullName | Should -FileContentMatch '.NOTES'
7172
}
72-
It "Should be an advanced function" {
73-
$CurrentFunction.FullName | Should -FileContentMatch 'function'
74-
$CurrentFunction.FullName | Should -FileContentMatch 'cmdletbinding'
75-
$CurrentFunction.FullName | Should -FileContentMatch 'param'
73+
It 'Should be an advanced function' -Skip:($Command.CommandType -ne 'Function' -or $Command.Name -in 'grep') -ForEach @{ Command = $Command } {
74+
$Command.CmdletBinding | Should -BeTrue
7675
}
7776
It "Should have Begin and End Regions" {
7877
$CurrentFunction.FullName | Should -FileContentMatch "#Region"

0 commit comments

Comments
 (0)