Tests/Unit/Get-RedirectUri.Tests.ps1

InModuleScope SpotifyUtils {
    BeforeAll {
        Import-Module "$PSScriptRoot\..\SUCommonTestFuncs.psm1"
        Mock Get-Content { Get-MockContent @PesterBoundParameters}
    }
    Describe "Get-RedirectUri" {
        It "Should return RedirectUri if passed in directly" {
            $r = Get-RedirectUri -Params @{RedirectUri = 'testme'}
            $r | Should -Be 'testme'
        }
        It "Should return ConfigFile's redirect if given ConfigFile" {
            Mock Test-Path { $true }
            $r = Get-RedirectUri -Params @{ConfigFile = 'mockfile.json'}
            $r | Should -Be 'http://localhost:8080'
        }
        It "Should return .env.json's redirect if no params are passed and .env.json exists" {
            $r = Get-RedirectUri
            $r | Should -Be 'http://localhost:8080'
        }
        It "Should throw an error if no params are passed and .env.json does not exist" {
            Mock Get-Content { throw "file does not exist" }
            { Get-RedirectUri } | Should -Throw
        }
    }
}