@@ -411,6 +411,30 @@ root:
411411 $documents [1 ][' drop' ] | Should - Be ' second'
412412 }
413413
414+ It ' treats an explicitly false AllDocuments switch as default nested selection' {
415+ $yaml = @'
416+ ---
417+ root:
418+ drop: first
419+ keep: one
420+ ---
421+ root:
422+ drop: second
423+ keep: two
424+ '@
425+ $defaultResult = Remove-YamlEntry $yaml ' /root/drop'
426+ $falseResult = Remove-YamlEntry $yaml ' /root/drop' - AllDocuments:$false
427+ $allResult = Remove-YamlEntry $yaml ' /root/drop' - AllDocuments
428+ $defaultDocuments = @ ($defaultResult | ConvertFrom-Yaml - AsHashtable)
429+ $allDocuments = @ ($allResult | ConvertFrom-Yaml - AsHashtable)
430+
431+ $falseResult | Should - BeExactly $defaultResult
432+ $defaultDocuments [0 ][' root' ].Contains(' drop' ) | Should - BeFalse
433+ $defaultDocuments [1 ][' root' ][' drop' ] | Should - Be ' second'
434+ $allDocuments [0 ][' root' ].Contains(' drop' ) | Should - BeFalse
435+ $allDocuments [1 ][' root' ].Contains(' drop' ) | Should - BeFalse
436+ }
437+
414438 It ' selects one explicit document index' {
415439 $yaml = " ---`n drop: first`n ---`n drop: second"
416440 $documents = @ (
@@ -459,6 +483,19 @@ root:
459483 $documents [1 ][' third' ] | Should - BeTrue
460484 }
461485
486+ It ' treats an explicitly false AllDocuments switch as default root selection' {
487+ $yaml = " ---`n first: true`n ---`n second: true"
488+ $defaultResult = Remove-YamlEntry $yaml ' '
489+ $falseResult = Remove-YamlEntry $yaml ' ' - AllDocuments:$false
490+ $allResult = Remove-YamlEntry $yaml ' ' - AllDocuments
491+ $defaultDocuments = @ ($defaultResult | ConvertFrom-Yaml - AsHashtable)
492+
493+ $falseResult | Should - BeExactly $defaultResult
494+ $defaultDocuments.Count | Should - Be 1
495+ $defaultDocuments [0 ][' second' ] | Should - BeTrue
496+ $allResult | Should - BeExactly ' '
497+ }
498+
462499 It ' removes all documents with AllDocuments and an empty pointer' {
463500 $result = @ (
464501 Remove-YamlEntry " ---`n first: true`n ---`n second: true" ' ' - AllDocuments
0 commit comments