Tests/Unit/Public/Workspaces/Get-SCAWorkspaceDelegation.Tests.ps1

Import-Module (Join-Path $PSScriptRoot '../../../../psSCA.psd1') -Force

Describe 'Get-SCAWorkspaceDelegation' {
    InModuleScope psSCA {
        It 'searches delegations with an empty body by default, marked idempotent' {
            Mock Invoke-SCARequest { }

            Get-SCAWorkspaceDelegation | Out-Null

            Should -Invoke Invoke-SCARequest -ParameterFilter {
                $Service -eq 'CEM' -and $Method -eq 'POST' -and $Path -eq '/delegations/workspace/search' -and $Idempotent -eq $true
            }
        }

        It 'passes -Filter through as the request body' {
            Mock Invoke-SCARequest { }

            Get-SCAWorkspaceDelegation -Filter @{ workspaceType = 'AWS' } | Out-Null

            Should -Invoke Invoke-SCARequest -ParameterFilter { $Body['workspaceType'] -eq 'AWS' }
        }
    }
}