mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-01 07:45:22 +03:00
Add tests for table of contents parser.
This commit is contained in:
parent
1a687c238a
commit
eb3a981dbf
38
examples/docs/tests/TableOfContentsTests.elm
Normal file
38
examples/docs/tests/TableOfContentsTests.elm
Normal file
@ -0,0 +1,38 @@
|
||||
module TableOfContentsTests exposing (..)
|
||||
|
||||
import Expect exposing (Expectation)
|
||||
import Fuzz exposing (Fuzzer, int, list, string)
|
||||
import Markdown.Block as Block exposing (..)
|
||||
import TableOfContents exposing (Entry(..))
|
||||
import Test exposing (..)
|
||||
|
||||
|
||||
suite : Test
|
||||
suite =
|
||||
describe "table of contents"
|
||||
[ test "flat" <|
|
||||
\() ->
|
||||
TableOfContents.buildToc
|
||||
[ Heading H2 [ Text "Top-Level Item 1" ]
|
||||
, Heading H2 [ Text "Top-Level Item 2" ]
|
||||
, Heading H2 [ Text "Top-Level Item 3" ]
|
||||
]
|
||||
|> Expect.equal
|
||||
[ Entry { anchorId = "top-level-item-1", level = 2, name = "Top-Level Item 1" } []
|
||||
, Entry { anchorId = "top-level-item-2", level = 2, name = "Top-Level Item 2" } []
|
||||
, Entry { anchorId = "top-level-item-3", level = 2, name = "Top-Level Item 3" } []
|
||||
]
|
||||
, test "nested" <|
|
||||
\() ->
|
||||
TableOfContents.buildToc
|
||||
[ Heading H2 [ Text "Top-Level Item 1" ]
|
||||
, Heading H3 [ Text "Nested under 1" ]
|
||||
, Heading H2 [ Text "Top-Level Item 3" ]
|
||||
]
|
||||
|> Expect.equal
|
||||
[ Entry { anchorId = "top-level-item-1", level = 2, name = "Top-Level Item 1" }
|
||||
[ Entry { anchorId = "nested-under-1", level = 3, name = "Nested under 1" } []
|
||||
]
|
||||
, Entry { anchorId = "top-level-item-3", level = 2, name = "Top-Level Item 3" } []
|
||||
]
|
||||
]
|
Loading…
Reference in New Issue
Block a user