From 7faa27a3b3aecd4bd5c1007f29b2149dd130ffbc Mon Sep 17 00:00:00 2001 From: dfinke Date: Thu, 4 Jul 2019 11:53:59 -0400 Subject: [PATCH] create xlsx before all in cwd --- __tests__/RelativePath.tests.ps1 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/__tests__/RelativePath.tests.ps1 b/__tests__/RelativePath.tests.ps1 index 1445b5b..7ae6fcf 100644 --- a/__tests__/RelativePath.tests.ps1 +++ b/__tests__/RelativePath.tests.ps1 @@ -1,22 +1,31 @@ Describe "Test reading relative paths" { + BeforeAll { + $script:xlfileName = "TestR.xlsx" + @{data = 1 } | Export-Excel "$pwd\TestR.xlsx" + } + + AfterAll { + Remove-Item "$pwd\$($script:xlfileName)" + } + It "Should read local file" { - $actual = Import-Excel -Path ".\testRelative.xlsx" + $actual = Import-Excel -Path ".\$($script:xlfileName)" $actual | Should Not Be $null - $actual.Count | Should Not Be 1 + $actual.Count | Should Be 1 } It "Should read with pwd" { - $actual = Import-Excel -Path "$pwd\testRelative.xlsx" + $actual = Import-Excel -Path "$pwd\$($script:xlfileName)" $actual | Should Not Be $null } It "Should read with PSScriptRoot" { - $actual = Import-Excel -Path "$PSScriptRoot\testRelative.xlsx" + $actual = Import-Excel -Path "$PSScriptRoot\$($script:xlfileName)" $actual | Should Not Be $null } It "Should read with just a file name and resolve to cwd" { - $actual = Import-Excel -Path "testRelative.xlsx" + $actual = Import-Excel -Path "$($script:xlfileName)" $actual | Should Not Be $null }