Functions/Test-MSPCompleteTaskShouldSkip.Tests.ps1

describe "BitTitan.Runbooks.MSPComplete/Test-MSPCompleteTaskShouldSkip" -Tag "module", "unit" {

    # Import the function to test
    . "$($PSScriptRoot)\Test-MSPCompleteTaskShouldSkip.ps1"

    # Declare mocks
    function Get-BT_RunbookEnvironment {
        return @{
            IsRunningOnLocalMachine = $true
        }
    }

    it "returns false when running on the local machine" {
        # Call the function
        $output = Test-MSPCompleteTaskShouldSkip

        # Verify the output
        $output | Should Be $false
    }

    # Declare mocks
    function Get-BT_RunbookEnvironment {
        return @{
            IsRunningOnLocalMachine = $false
        }
    }
    function Find-StringInMSPCompleteTaskInputs {
        param ($SearchString, [Switch]$CaseSensitive)
        return $true
    }

    it "returns true if 'SKIP_MSPC_TASK' is found in the task string inputs" {
        # Call the function
        $output = Test-MSPCompleteTaskShouldSkip

        # Verify the output
        $output | Should Be $true
    }

    # Declare mocks
    function Find-StringInMSPCompleteTaskInputs {
        param ($SearchString, [Switch]$CaseSensitive)
        return $false
    }
    $mspc.Data = @{
        SKIP_MSPC_TASK_1 = "true"
    }
    $mspc.AutomationInstanceId = "1"
    it "returns true if the entry in `$mspc.Data is true" {
        # Call the function
        $output = Test-MSPCompleteTaskShouldSkip

        # Verify the output
        $output | Should Be $true
    }

    # Declare mocks
    function Find-StringInMSPCompleteTaskInputs {
        param ($SearchString, [Switch]$CaseSensitive)
        return $false
    }
    $mspc.Data = @{}

    it "returns false if none of the conditions are true" {
        # Call the function
        $output = Test-MSPCompleteTaskShouldSkip

        # Verify the output
        $output | Should Be $false
    }

}