See the tests/parser/toc.txt file in Parsoid which specs out TOC metadata for wikitext.
As the file documents in comments for various tests, when the content comes from templates (or parser functions or extensions), Parsoid's output and legacy parser output differ. We should reconcile these differences depending on expectations for this metadata by other products / code.