-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor cmdlet * test case for inputting two VanityURLs * refactor * fix mock api key * add tag * single quotes * comment based help
- Loading branch information
Showing
2 changed files
with
60 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,37 @@ | ||
Describe "Resolve-VanityURL Tests" { | ||
Context "When resolving a valid VanityURL" { | ||
Describe 'Resolve-VanityURL Tests' -Tag 'Unit' { | ||
BeforeAll { | ||
. $SteamPSModulePath\Private\API\Get-SteamAPIKey.ps1 | ||
Mock -CommandName Get-SteamAPIKey -ModuleName SteamPS -MockWith { | ||
return $true | ||
} | ||
} | ||
|
||
Context 'When resolving a valid VanityURL' { | ||
BeforeAll { | ||
Mock Resolve-VanityURL { | ||
return [PSCustomObject]@{ | ||
'SteamID64' = 1234567890 | ||
} | ||
} | ||
Mock -CommandName Invoke-RestMethod -ModuleName SteamPS -MockWith { | ||
return '{"response":{"steamid":"7656119711117235","success": 1}}' | ConvertFrom-Json | ||
} # Mock | ||
} | ||
It "Should return a PSCustomObject with SteamID64" { | ||
$result = Resolve-VanityURL -VanityURL "validVanityURL" | ||
$result.SteamID64 | Should -BeExactly 1234567890 | ||
It 'Should return a PSCustomObject with SteamID64' { | ||
(Resolve-VanityURL -VanityURL 'Toby').SteamID64 | Should -BeExactly 7656119711117235 | ||
} | ||
} | ||
|
||
Context "When resolving an invalid VanityURL" { | ||
It "Should throw an error" { | ||
{ Resolve-VanityURL -VanityURL "invalidVanityURL" } | Should -Throw | ||
Context 'When resolving an invalid VanityURL' { | ||
BeforeAll { | ||
Mock -CommandName Invoke-RestMethod -ModuleName SteamPS -MockWith { | ||
return '{"response":{"success": 42,"message": "No match"}}' | ConvertFrom-Json | ||
} # Mock | ||
} | ||
|
||
It 'Should throw an error' { | ||
{ Resolve-VanityURL -VanityURL 'invalidVanityURL' -ErrorAction Stop } | Should -Throw | ||
} | ||
} | ||
|
||
Context "When resolving an invalid, fully qualified VanityURL" { | ||
It "Should throw an error" { | ||
{ Resolve-VanityURL -VanityURL "https://steamcommunity.com/id/test" } | Should -Throw | ||
Context 'When resolving an invalid, fully qualified VanityURL' { | ||
It 'Should throw an error' { | ||
{ Resolve-VanityURL -VanityURL 'https://steamcommunity.com/id/test' } | Should -Throw | ||
} | ||
} | ||
} |