Skip to content

Commit e894bbb

Browse files
authored
Merge pull request #163 from lipkau/fix/#162-MultipleHeaderInTable
Fix multiple header in table
2 parents b176b23 + 41bb449 commit e894bbb

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

ConfluencePS/Public/ConvertTo-Table.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ function ConvertTo-Table {
1717
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
1818

1919
$sb = [System.Text.StringBuilder]::new()
20+
21+
$HeaderGenerated = $NoHeader
2022
}
2123

2224
PROCESS {
2325
Write-Debug "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)"
2426
Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"
2527

26-
$HeaderGenerated = $NoHeader
27-
2828
# This ForEach needed if the content wasn't piped in
2929
$Content | ForEach-Object {
3030
If ($Vertical) {

Tests/Functions/ConvertTo-Table.Tests.ps1

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,54 +56,54 @@ Describe 'ConvertTo-Table' -Tag Unit {
5656
# linux and macOS don't have Fake
5757
function Get-FakeService {
5858
[PSCustomObject]@{
59-
Name = "AppMgmt"
59+
Name = "AppMgmt"
6060
DisplayName = "Application Management"
61-
Status = "Running"
61+
Status = "Running"
6262
}
6363
[PSCustomObject]@{
64-
Name = "BITS"
64+
Name = "BITS"
6565
DisplayName = "Background Intelligent Transfer Service"
66-
Status = "Running"
66+
Status = "Running"
6767
}
6868
[PSCustomObject]@{
69-
Name = "Dhcp"
69+
Name = "Dhcp"
7070
DisplayName = "DHCP Client"
71-
Status = "Running"
71+
Status = "Running"
7272
}
7373
[PSCustomObject]@{
74-
Name = "DsmSvc"
74+
Name = "DsmSvc"
7575
DisplayName = "Device Setup Manager"
76-
Status = "Running"
76+
Status = "Running"
7777
}
7878
[PSCustomObject]@{
79-
Name = "EFS"
79+
Name = "EFS"
8080
DisplayName = "Encrypting File System (EFS)"
81-
Status = "Running"
81+
Status = "Running"
8282
}
8383
[PSCustomObject]@{
84-
Name = "lmhosts"
84+
Name = "lmhosts"
8585
DisplayName = "TCP/IP NetBIOS Helper"
86-
Status = "Running"
86+
Status = "Running"
8787
}
8888
[PSCustomObject]@{
89-
Name = "MSDTC"
89+
Name = "MSDTC"
9090
DisplayName = "Distributed Transaction Coordinator"
91-
Status = "Stopped"
91+
Status = "Stopped"
9292
}
9393
[PSCustomObject]@{
94-
Name = "NlaSvc"
94+
Name = "NlaSvc"
9595
DisplayName = "Network Location Awareness"
96-
Status = "Stopped"
96+
Status = "Stopped"
9797
}
9898
[PSCustomObject]@{
99-
Name = "PolicyAgent"
99+
Name = "PolicyAgent"
100100
DisplayName = "IPsec Policy Agent"
101-
Status = "Stopped"
101+
Status = "Stopped"
102102
}
103103
[PSCustomObject]@{
104-
Name = "SessionEnv"
104+
Name = "SessionEnv"
105105
DisplayName = "Remote Desktop Configuration"
106-
Status = "Stopped"
106+
Status = "Stopped"
107107
}
108108
}
109109
#endregion Mocking
@@ -204,5 +204,19 @@ Describe 'ConvertTo-Table' -Tag Unit {
204204
@($table).Count | Should -Be 1
205205
@($row).Count | Should -BeGreaterThan 1
206206
}
207+
208+
It "returns a single table when using the pipeline" {
209+
$table = Get-FakeService | ConvertTo-ConfluenceTable
210+
$row = $table -split [Environment]::NewLine
211+
212+
$row | Should -HaveCount 12
213+
$row[0] | Should -BeExactly '|| Name || DisplayName || Status ||'
214+
$row[1..10] | ForEach-Object {
215+
$_ | Should -Match '^| [\w\s]+? | [\w\s]+? | [\w\s]+? |$'
216+
$_ | Should -Not -Match '\|\|'
217+
$_ | Should -Not -Match '\|\s\s+\|'
218+
}
219+
$row[11] | Should -BeNullOrEmpty
220+
}
207221
}
208222
}

0 commit comments

Comments
 (0)