tests/Add-SkylineFiles.Tests.ps1

Describe "Add-SkylineFiles" {
    BeforeAll {
        $TempPath = (Get-Item "TestDrive:\").FullName
        
        New-Item -ItemType File -Force -Path "$TempPath\assets\webparts\testwidget.html" -Value "some webpart html"
        New-Item -ItemType File -Force -Path "$TempPath\assets\libs\jquery.min.js" -Value "some jquery"
        New-Item -ItemType File -Force -Path "$TempPath\assets\libs\bootstrap.min.js" -Value "some bootstrap"
    }
    Context "uploads .js files to style library" {

        It "should upload files with -Includes *.js -Excludes *bootstrap*" {
            Add-SkylineFiles -Path $TempPath -Folder "/Style Library/tests" -Includes "*.js" -Excludes "*bootstrap*" -Checkout 
        }

        It "should find a jquery.min.js file in the style library" {
            Get-PnPFile -Url "/Style Library/tests/assets/libs/jquery.min.js" -AsString | Should Be "some jquery"
        }

        It "should NOT find a bootstrap.min.js file in the style library" {
            Get-PnPFile -Url "/Style Library/tests/assets/libs/bootstrap.min.js" -AsString -EA 0 | Should BeNullOrEmpty
        }

        It "should NOT find a testwidget.html file in the style library" {
            Get-PnPFile -Url "/Style Library/tests/webparts/testwidget.html" -AsString -EA 0 | Should BeNullOrEmpty
        }
    }
    AfterAll {
        Remove-PnPFolder -Folder "/Style Library" -Name "Tests" -Force
    }
}