diff --git a/src/Functions/Public/Get-SWAPISpecies.ps1 b/src/Functions/Public/Get-SWAPISpecies.ps1 index 7823673..4808511 100644 --- a/src/Functions/Public/Get-SWAPISpecies.ps1 +++ b/src/Functions/Public/Get-SWAPISpecies.ps1 @@ -8,7 +8,7 @@ function Get-SWAPISpecies { process { $invokeSwapiReqParams = @{ Method = 'Get' - Path = 'species' + Path = 'species' } if ($PSBoundParameters.ContainsKey('Name')) { diff --git a/tests/Get-SWAPIFilm.tests.ps1 b/tests/Get-SWAPIFilm.tests.ps1 new file mode 100644 index 0000000..b5259ed --- /dev/null +++ b/tests/Get-SWAPIFilm.tests.ps1 @@ -0,0 +1,58 @@ +BeforeAll { + Import-Module $PSScriptRoot/../src/PSSWAPI.psd1 -Force +} + +Describe 'Get-SWAPIFilm' { + Context 'When no parameters are passed' { + BeforeAll { + Mock -ModuleName PSSWAPI Get-SWAPIFilm { + return @( + @{ + 'Title' = 'A New Hope' + 'Episode' = 4 + 'Opening Crawl' = 'It is a period of civil war.…' + 'Director' = 'George Lucas' + 'Release Date' = '1977-05-25' + } + @{ + 'Title' = 'The Empire Strikes Back' + 'Episode' = 5 + 'Opening Crawl' = 'It is a dark time for the…' + 'Director' = 'Irvin Kershner' + 'Release Date' = '1980-05-17' + } + ) + } + $result = Get-SWAPIFilm + } + + It 'Returns more than 1 movie' { + ($result | Measure-Object).Count | Should -BeGreaterThan 1 + } + } + + Context 'When "Title" parameter is passed' { + BeforeAll { + Mock -ModuleName PSSWAPI Get-SWAPIFilm -Verifiable -ParameterFilter { $Title -eq 'The Empire Strikes Back' } { + return @( + @{ + 'Title' = 'The Empire Strikes Back' + 'Episode' = 5 + 'Opening Crawl' = 'It is a dark time for the…' + 'Director' = 'Irvin Kershner' + 'Release Date' = '1980-05-17' + } + ) + } + $result = Get-SWAPIFilm -Title 'The Empire Strikes Back' + } + + It 'Returns more than 1 movie' { + ($result | Measure-Object).Count | Should -Be 1 + } + + It 'Returns the movie matching the title' { + $result.Title | Should -Be 'The Empire Strikes Back' + } + } +} diff --git a/tests/Manifest.Tests.ps1 b/tests/Manifest.Tests.ps1 index e346f78..a140743 100644 --- a/tests/Manifest.Tests.ps1 +++ b/tests/Manifest.Tests.ps1 @@ -68,7 +68,7 @@ Describe 'Module Structure and Syntax' { } } - Context "Function Syntax - <_.BaseName>" -ForEach $functionsAll { + Context "Function Syntax: <_.BaseName>" -ForEach $functionsAll { It 'has no syntax errors' { @@ -82,7 +82,7 @@ Describe 'Module Structure and Syntax' { } } - Context "Public Function Exported - <_.BaseName>" -ForEach $functionsPublic { + Context "Public Function Exported: <_.BaseName>" -ForEach $functionsPublic { It 'is exported in the module manifest' { $manifest.ExportedCommands.Keys.GetEnumerator() -contains $_.BaseName | Should -Be $true