Functions/Get-Puppeteer_SetChromeBrowserOptions.Tests.ps1

describe "BitTitan.Runbooks.UIAutomation/Get-Puppeteer_SetChromeBrowserOptions" -Tag "module", "unit" {

    # Import the function to test
    . "$($PSScriptRoot)\Get-Puppeteer_SetChromeBrowserOptions.ps1"

    it "returns the code for setting the chrome browser options as headless" {
        # Call the function
        $output = Get-Puppeteer_SetChromeBrowserOptions -IsHeadless $true -Width 1920 -Height 1080

        # Verify the output
        $output | Should Be @"
// Create object to store the Chrome browser options
chromeBrowserOptions = {};
 
// Select whether Chrome will be executed as headless (no GUI)
chromeBrowserOptions.headless = true;
 
// Set default viewport to be larger, otherwise some page elements will not be available
chromeBrowserOptions.defaultViewport = Object;
chromeBrowserOptions.defaultViewport.width = 1920;
chromeBrowserOptions.defaultViewport.height = 1080;
"@

    }

    it "returns the code for setting the chrome browser options as not headless" {
        # Call the function
        $output = Get-Puppeteer_SetChromeBrowserOptions -IsHeadless $false -Width 1920 -Height 1080

        # Verify the output
        $output | Should Be @"
// Create object to store the Chrome browser options
chromeBrowserOptions = {};
 
// Select whether Chrome will be executed as headless (no GUI)
chromeBrowserOptions.headless = false;
 
// Set default viewport to be larger, otherwise some page elements will not be available
chromeBrowserOptions.defaultViewport = Object;
chromeBrowserOptions.defaultViewport.width = 1920;
chromeBrowserOptions.defaultViewport.height = 1080;
"@

    }
}