# SPDX-License-Identifier: MIT # Copyright (c) 2026 Rug Munch Media LLC # # Part of Pry — https://git.rugmunch.io/RugMunchMedia/pryscraper # Licensed under MIT. See LICENSE. """Tests for shadow DOM flattening.""" from shadow_dom import ShadowDOMProcessor, flatten_shadow_dom, has_shadow_dom def test_has_shadow_dom_detected() -> None: html = '
Shadow content
' assert has_shadow_dom(html) is True def test_has_shadow_dom_not_detected() -> None: html = "Regular content
" assert has_shadow_dom(html) is False def test_flatten_shadow_dom_open() -> None: html = 'Shadow content
Hidden
Hello
" result = processor.process(html) assert result == html def test_processor_with_shadow() -> None: processor = ShadowDOMProcessor() html = 'In shadow
' result = processor.process(html) assert "In shadow" in result assert "template" not in result def test_has_shadow_dom_attach_shadow() -> None: html = "" assert has_shadow_dom(html) is True def test_has_shadow_dom_shadowroot_string() -> None: html = "" assert has_shadow_dom(html) is True