Functions/New-TextBlock.Tests.ps1

describe "BitTitan.Runbooks.Common/New-TextBlock" -Tag "module", "unit" {

    # Import the function to test
    . "$($PSScriptRoot)\New-TextBlock.ps1"

    it "generates a text block" {
        # Call the function
        $output = New-TextBlock {
            "line1"
            "line2"
            "line3"
        }

        # Verify the output
        $output | Should Be @"
    line1
    line2
    line3
"@

    }

    it "generates a text block with the specified indentation amount" {
        # Call the function
        $output = New-TextBlock {
            "line1"
            "line2"
            "line3"
        } -IndentationAmount 2

        # Verify the output
        $output | Should Be @"
  line1
  line2
  line3
"@

    }

    it "generates a text block with the specified number of newline characters added to the end" {
        # Call the function
        $output = New-TextBlock {
            "line1"
            "line2"
            "line3"
        } -AppendNewLines 3

        # Verify the output
        $output | Should Be @"
    line1
    line2
    line3
 
 
 
"@

    }

    it "generates a text block using nested text blocks" {
        $output = New-TextBlock {
            "outerLine1"
            New-TextBlock {
                "innerLine1"
                New-TextBlock {
                    "innerInnerLine1"
                    "innerInnerLine2"
                }
                "innerLine2"
            }
            "outerLine2"
        }
        # Verify the output
        $output | Should Be @"
    outerLine1
        innerLine1
            innerInnerLine1
            innerInnerLine2
        innerLine2
    outerLine2
"@

    }

}