tests/Add-SkylineCSSLinkCustomAction.Tests.ps1

Describe "Add-SkylineCSSLinkCustomAction" {
    BeforeAll {

    }
    Context "create a new custom action which pulls in bootstrap css" {
        It "should create new css link custom action" {
            Add-SkylineCSSLinkCustomAction -Name "CssLinkCustomActionTest" -Url "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
        }
        It "should have created the new custom action" {
            Get-PnPCustomAction | Where-Object { $_.Name -eq "CssLinkCustomActionTest" } | Should Not BeNullOrEmpty
        }
        It "should have added a bootstrap cdn css url to site" {
            $CustomAction = Get-PnPCustomAction | Where-Object { $_.Name -eq "CssLinkCustomActionTest" }
            $CustomAction.ScriptBlock | Should BeLike "*https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css*"
        }
        It "should not have set the body to hide on load" {
            $CustomAction = Get-PnPCustomAction | Where-Object { $_.Name -eq "CssLinkCustomActionTest" }
            $CustomAction.ScriptBlock | Should Not BeLike "*body { opacity: 0 }*"
        }
    }
    Context "overwrites existing custom action with materialize css and hides body on load" {
        It "should overwrite css link custom action" {
            Add-SkylineCSSLinkCustomAction -HideBodyOnLoad -Name "CssLinkCustomActionTest" -Url "https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.1/css/materialize.min.css"
        }
        It "should have updated css url to materialize instead of bootstrap" {
            $CustomAction = Get-PnPCustomAction | Where-Object { $_.Name -eq "CssLinkCustomActionTest" }
            $CustomAction.ScriptBlock | Should BeLike "*https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.1/css/materialize.min.css*"
        }
        It "should have set the body to hide on load" {
            $CustomAction = Get-PnPCustomAction | Where-Object { $_.Name -eq "CssLinkCustomActionTest" }
            $CustomAction.ScriptBlock | Should BeLike "*body { opacity: 0 }*"
        }
    }
    AfterAll {
        $CustomAction = Get-PnPCustomAction | Where-Object { $_.Name -eq "CssLinkCustomActionTest" } 
        Remove-PnPCustomAction -Identity $CustomAction.Id -Force 
    }
}