Added some hyperlink tests

This commit is contained in:
dfinke
2022-12-27 16:06:07 -05:00
parent 16820a30c4
commit 2642211e12
2 changed files with 88 additions and 5 deletions

View File

@@ -1207,4 +1207,82 @@ Describe ExportExcel -Tag "ExportExcel" {
Close-ExcelPackage $excel -NoSave
}
}
It "Should have hyperlink created" -Tag hyperlink {
$path = "TestDrive:\testHyperLink.xlsx"
$license = "cognc:MCOMEETADV_GOV,cognc:M365_G3_GOV,cognc:ENTERPRISEPACK_GOV,cognc:RIGHTSMANAGEMENT_ADHOC"
$ms365 = [PSCustomObject]@{
DisplayName = "Test Subject"
UserPrincipalName = "test@contoso.com"
licenses = $license
}
$ms365 | Export-Excel $path
$excel = Open-ExcelPackage $Path
$ws = $excel.Sheet1
$ws.Dimension.Rows | Should -Be 2
$ws.Dimension.Columns | Should -Be 3
$ws.Cells["C2"].Hyperlink | Should -BeExactly $license
Close-ExcelPackage $excel
Remove-Item $path
}
It "Should have no hyperlink created" -Tag hyperlink {
$path = "TestDrive:\testHyperLink.xlsx"
$license = "cognc:MCOMEETADV_GOV,cognc:M365_G3_GOV,cognc:ENTERPRISEPACK_GOV,cognc:RIGHTSMANAGEMENT_ADHOC"
$ms365 = [PSCustomObject]@{
DisplayName = "Test Subject"
UserPrincipalName = "test@contoso.com"
licenses = $license
}
$ms365 | Export-Excel $path -NoHyperLinkConversion licenses
$excel = Open-ExcelPackage $Path
$ws = $excel.Sheet1
$ws.Dimension.Rows | Should -Be 2
$ws.Dimension.Columns | Should -Be 3
$ws.Cells["C2"].Hyperlink | Should -BeNullOrEmpty
Close-ExcelPackage $excel
Remove-Item $path
}
It "Should have no hyperlink created using wild card" -Tag hyperlink {
$path = "TestDrive:\testHyperLink.xlsx"
$license = "cognc:MCOMEETADV_GOV,cognc:M365_G3_GOV,cognc:ENTERPRISEPACK_GOV,cognc:RIGHTSMANAGEMENT_ADHOC"
$ms365 = [PSCustomObject]@{
DisplayName = "Test Subject"
UserPrincipalName = "test@contoso.com"
licenses = $license
}
$ms365 | Export-Excel $path -NoHyperLinkConversion *
$excel = Open-ExcelPackage $Path
$ws = $excel.Sheet1
$ws.Dimension.Rows | Should -Be 2
$ws.Dimension.Columns | Should -Be 3
$ws.Cells["A2"].Value | Should -BeExactly "Test Subject"
$ws.Cells["B2"].Value | Should -BeExactly "test@contoso.com"
$ws.Cells["C2"].Hyperlink | Should -BeNullOrEmpty
Close-ExcelPackage $excel
Remove-Item $path
}
}

View File

@@ -1,3 +1,8 @@
# 7.8.x
Thanks to [Thomas Hofkens](https://github.com/thkn-hofa)
- Added `-NoHyperLinkConversion` to `Export-Excel` to no convert data to hyperlinks. [#1316](https://github.com/dfinke/ImportExcel/issues/1316)
# 7.8.4
- Add -ShowOnlyIcon to `New-ConditionalFormattingIconSet` does not show data in the cell, just the icon. Based on this discussion https://github.com/dfinke/ImportExcel/discussions/1340