def test_typescript_code_splitter() -> None:
    """Test case for code splitting using TypeScript."""
    if "CI" in os.environ:
        return

    code_splitter = CodeHierarchyNodeParser(
        language="typescript", skeleton=True, chunk_min_characters=0
    )

    text = """\
function foo() {
    console.log("bar");
}

class Example {
    exampleMethod() {
        console.log("line1");
    }
}

function baz() {
    console.log("bbq");
}"""

    text_node = TextNode(
        text=text,
    )
    chunks: List[RelatedNodeInfo] = code_splitter.get_nodes_from_documents([text_node])

    # Fstrings don't like forward slash
    double_forward_slash: str = "//"
    assert (
        chunks[0].text
        == f"""\
function foo() {{
    {double_forward_slash} {CodeHierarchyNodeParser._get_comment_text(chunks[1])}
}}

class Example {{
    {double_forward_slash} {CodeHierarchyNodeParser._get_comment_text(chunks[2])}
}}

function baz() {{
    {double_forward_slash} {CodeHierarchyNodeParser._get_comment_text(chunks[4])}
}}"""
    )

    # Test the second chunk (function foo)
    assert (
        chunks[1].text
        == """\
function foo() {
    console.log("bar");
}"""
    )
    assert chunks[1].metadata["inclusive_scopes"] == [
        {"name": "foo", "type": "function_declaration", "signature": "function foo()"}
    ]
    assert (
        cast(RelatedNodeInfo, chunks[1].relationships[NodeRelationship.PARENT]).node_id
        == chunks[0].id_
    )
    assert [c.node_id for c in chunks[1].relationships[NodeRelationship.CHILD]] == []

    # Test the third chunk (class Example)
    assert (
        chunks[2].text
        == f"""\
class Example {{
    exampleMethod() {{
        {double_forward_slash} {CodeHierarchyNodeParser._get_comment_text(chunks[3])}
    }}
}}"""
    )
    assert chunks[2].metadata["inclusive_scopes"] == [
        {"name": "Example", "type": "class_declaration", "signature": "class Example"}
    ]
    assert (
        cast(RelatedNodeInfo, chunks[2].relationships[NodeRelationship.PARENT]).node_id
        == chunks[0].id_
    )
    assert [c.node_id for c in chunks[2].relationships[NodeRelationship.CHILD]] == [
        chunks[3].id_
    ]

    # Test the fourth chunk (exampleMethod in class Example)
    assert (
        chunks[3].text
        == """\
    exampleMethod() {
        console.log("line1");
    }"""
    )
    assert chunks[3].metadata["inclusive_scopes"] == [
        {"name": "Example", "type": "class_declaration", "signature": "class Example"},
        {
            "name": "exampleMethod",
            "type": "method_definition",
            "signature": "exampleMethod()",
        },
    ]
    assert (
        cast(RelatedNodeInfo, chunks[3].relationships[NodeRelationship.PARENT]).node_id
        == chunks[2].id_
    )
    assert chunks[3].relationships[NodeRelationship.CHILD] == []

    # Test the fifth chunk (function baz)
    assert (
        chunks[4].text
        == """\
function baz() {
    console.log("bbq");
}"""
    )
    assert chunks[4].metadata["inclusive_scopes"] == [
        {"name": "baz", "type": "function_declaration", "signature": "function baz()"}
    ]
    assert (
        cast(RelatedNodeInfo, chunks[4].relationships[NodeRelationship.PARENT]).node_id
        == chunks[0].id_
    )
    assert chunks[4].relationships[NodeRelationship.CHILD] == []
Test case for code splitting using TypeScript.
llama-index-packs/llama-index-packs-code-hierarchy/tests/test_code_hierarchy_with_skeleton.py