def test_create_document_root():
    """Test that the document root is created correctly."""
    # Test with no components.
    root = utils.create_document_root()
    root.render()
    assert isinstance(root, utils.Html)
    assert isinstance(root.children[0], utils.DocumentHead)
    # Default language.
    assert root.lang == "en"  # pyright: ignore [reportAttributeAccessIssue]
    # No children in head.
    assert len(root.children[0].children) == 0

    # Test with components.
    comps = [
        utils.NextScript.create(src="foo.js"),
        utils.NextScript.create(src="bar.js"),
    ]
    root = utils.create_document_root(
        head_components=comps,
        html_lang="rx",
        html_custom_attrs={"project": "reflex"},
    )
    # Two children in head.
    assert isinstance(root, utils.Html)
    assert len(root.children[0].children) == 2
    assert root.lang == "rx"  # pyright: ignore [reportAttributeAccessIssue]
    assert isinstance(root.custom_attrs, dict)
    assert root.custom_attrs == {"project": "reflex"}
Test that the document root is created correctly.
tests/units/compiler/test_compiler.py