mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Add unit tests for Get-ExcelFileSummary #1014
This commit is contained in:
43
__tests__/Get-ExcelFileSummary.Tests.ps1
Normal file
43
__tests__/Get-ExcelFileSummary.Tests.ps1
Normal file
@@ -0,0 +1,43 @@
|
||||
#Requires -Modules Pester
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'False Positives')]
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidAssignmentToAutomaticVariable', '', Justification = 'Only executes on versions without the automatic variable')]
|
||||
param()
|
||||
|
||||
if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
|
||||
Import-Module $PSScriptRoot\..\ImportExcel.psd1
|
||||
}
|
||||
|
||||
Describe 'All tests for Get-ExcelFileSummary' -Tag "Get-ExcelFileSummary" {
|
||||
Context "Test Get-ExcelFileSummary" {
|
||||
It "Tests summary on TestData2.xlsx" {
|
||||
$actual = Get-ExcelFileSummary "$PSScriptRoot\ImportExcelTests\TestData1.xlsx"
|
||||
|
||||
$actual.ExcelFile | Should -BeExactly 'TestData1.xlsx'
|
||||
$actual.WorksheetName | Should -BeExactly 'Sheet1'
|
||||
$actual.Rows | Should -Be 3
|
||||
$actual.Columns | Should -Be 2
|
||||
$actual.Address | Should -BeExactly 'A1:B3'
|
||||
$actual.Path | Should -BeExactly "$PSScriptRoot\ImportExcelTests"
|
||||
}
|
||||
|
||||
It "Tests summary on xlsx with multiple sheets" {
|
||||
|
||||
$actual = Get-ExcelFileSummary "$PSScriptRoot\ImportExcelTests\MultipleSheets.xlsx"
|
||||
|
||||
$actual[0].ExcelFile | Should -BeExactly 'MultipleSheets.xlsx'
|
||||
$actual[0].WorksheetName | Should -BeExactly 'Sheet1'
|
||||
$actual[0].Rows | Should -Be 1
|
||||
$actual[0].Columns | Should -Be 4
|
||||
$actual[0].Address | Should -BeExactly 'A1:D1'
|
||||
$actual[0].Path | Should -BeExactly "$PSScriptRoot\ImportExcelTests"
|
||||
|
||||
$actual[1].ExcelFile | Should -BeExactly 'MultipleSheets.xlsx'
|
||||
$actual[1].WorksheetName | Should -BeExactly 'Sheet2'
|
||||
$actual[1].Rows | Should -Be 2
|
||||
$actual[1].Columns | Should -Be 2
|
||||
$actual[1].Address | Should -BeExactly 'A1:B2'
|
||||
$actual[1].Path | Should -BeExactly "$PSScriptRoot\ImportExcelTests"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
BIN
__tests__/ImportExcelTests/MultipleSheets.xlsx
Normal file
BIN
__tests__/ImportExcelTests/MultipleSheets.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user