tests/Add-SkylineFieldIndex.Tests.ps1
$FieldName = "FieldIndexTest" $ListName = "Documents" Describe "Add-SkylineFieldIndex - Root Web" { BeforeAll { Add-PnPField -List $ListName -DisplayName $FieldName -InternalName $FieldName -Type Text | Out-Null } Context "indexes the $FieldName field of the $ListName list on the root web" { It "should not be indexed" { $Field = Get-PnPField -Identity $FieldName -List $ListName $Field.Indexed | Should Be $false } It "should add the index" { Add-SkylineFieldIndex -Identity $FieldName -List $ListName } It "should be indexed" { $Field = Get-PnPField -Identity $FieldName -List $ListName $Field.Indexed | Should Be $true } } AfterAll { Remove-PnPField -Identity $FieldName -List $ListName -Force } } Describe "Add-SkylineFieldIndex - Subsite" { BeforeAll { $Subsite = @(Get-PnPSubWebs)[0] Add-PnPField -List $ListName -DisplayName $FieldName -InternalName $FieldName -Type Text -Web $Subsite | Out-Null } Context "indexes the $FieldName field of the $ListName list on the subsite" { It "should not be indexed" { $Field = Get-PnPField -Identity $FieldName -List $ListName -Web $Subsite $Field.Indexed | Should Be $false } It "should add the index" { Add-SkylineFieldIndex -Identity $FieldName -List $ListName -Web $Subsite } It "should be indexed" { $Field = Get-PnPField -Identity $FieldName -List $ListName -Web $Subsite $Field.Indexed | Should Be $true } } AfterAll { Remove-PnPField -Identity $FieldName -List $ListName -Web $Subsite -Force } } |