forked from dfinke/ImportExcel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPath.tests.ps1
More file actions
38 lines (31 loc) · 1.36 KB
/
Copy pathPath.tests.ps1
File metadata and controls
38 lines (31 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Describe "Test reading relative paths" {
BeforeAll {
$script:xlfileName = "TestR.xlsx"
@{data = 1 } | Export-Excel (Join-Path $PWD "TestR.xlsx")
}
AfterAll {
Remove-Item (Join-Path $PWD "$($script:xlfileName)")
}
It "Should read local file".PadRight(90) {
$actual = Import-Excel -Path ".\$($script:xlfileName)"
$actual | Should -Not -Be $null
$actual.Count | Should -Be 1
}
It "Should read with pwd".PadRight(90){
$actual = Import-Excel -Path (Join-Path $PWD "$($script:xlfileName)")
$actual | Should -Not -Be $null
}
It "Should read with just a file name and resolve to cwd".PadRight(90){
$actual = Import-Excel -Path "$($script:xlfileName)"
$actual | Should -Not -Be $null
}
It "Should fail for not found".PadRight(90){
{ Import-Excel -Path "ExcelFileDoesNotExist.xlsx" } | Should -Throw "'ExcelFileDoesNotExist.xlsx' file not found"
}
It "Should fail for xls extension".PadRight(90){
{ Import-Excel -Path "ExcelFileDoesNotExist.xls" } | Should -Throw "Import-Excel does not support reading this extension type .xls"
}
It "Should fail for xlsxs extension".PadRight(90){
{ Import-Excel -Path "ExcelFileDoesNotExist.xlsxs" } | Should -Throw "Import-Excel does not support reading this extension type .xlsxs"
}
}