Skip to content

Commit

Permalink
Correction of expected format
Browse files Browse the repository at this point in the history
  • Loading branch information
rpothin authored Sep 20, 2023
1 parent 2df7556 commit 74d5835
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions Scripts/ConvertTo-MarkdownTable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ function ConvertTo-MarkdownTable {
[psobject]$InputObject
)

Begin {
# Initialize variables
$headersDone = $false
$pattern = '(?<!\\)\|' # escape every '|' unless already escaped
}

Process {
# Check that the input object is of type psobject
if ($InputObject.GetType().Name -ne 'PSCustomObject') {
Expand All @@ -44,11 +50,7 @@ function ConvertTo-MarkdownTable {
if ($inputObjectAsJson -eq "{}" -or $inputObjectAsJson -eq "[]") {
throw "The input object is empty."
}

# Initialize variables
$headersDone = $false
$pattern = '(?<!\\)\|' # escape every '|' unless already escaped


# If the headers are not configured yet, configure them
if (!$headersDone) {
$headersDone = $true
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Tests/ConvertTo-MarkdownTable.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Describe "ConvertTo-MarkdownTable Unit Tests" {
}
)
$result = $inputObject | ConvertTo-MarkdownTable
$result | Should -Be @('|Property1|Property2|Property3|', '|---------|---------|---------|', '|Value1|Value2|Value3|', '|Property1|Property2|Property3|', '|---------|---------|---------|', '|Value1|Value2|Value3|', '|Property1|Property2|Property3|', '|---------|---------|---------|', '|Value1|Value2|Value3|')
$result | Should -Be @('|Property1|Property2|Property3|', '|---------|---------|---------|', '|Value1|Value2|Value3|', '|Value1|Value2|Value3|', '|Value1|Value2|Value3|')
}
}
}

0 comments on commit 74d5835

Please sign in to comment.