souplesse/tests/TrackTest.elm

43 lines
1.4 KiB
Elm
Raw Normal View History

2024-10-23 22:37:29 +00:00
module TrackTest exposing (specs)
import Fixtures
import Track exposing (Track, Point)
2024-10-23 22:37:29 +00:00
import Test exposing (..)
import Expect exposing (Expectation)
import Time
2024-10-23 22:37:29 +00:00
specs: Test
specs =
describe "XML Parsing"
[ test "it parses points" <|
\_ ->
case Track.parse Fixtures.threepoints of
(Ok trk) -> Expect.equalLists Fixtures.threepoints_expected trk
_ -> Expect.fail "not ok"
, test "missing child ele node in track point" <|
\_ ->
let
xml = String.replace
"<ele>64.8</ele>"
""
Fixtures.threepoints
in
case Track.parse xml of
2024-10-24 22:06:00 +00:00
Ok (p::pts) -> Expect.equal p (Point (51.600643, -0.01856, Nothing) (Just (Time.millisToPosix 1729669252256)))
Ok _ -> Expect.fail "empty list"
(Err f) -> Expect.fail f
, test "multiple trksegs are coalesced" <|
2024-10-23 22:37:29 +00:00
\_ ->
let
xml = String.replace
"<!-- insert-segment -->"
"</trkseg><trkseg>"
Fixtures.threepoints
2024-10-23 22:37:29 +00:00
in
case Track.parse xml of
(Ok trk) -> Expect.equalLists Fixtures.threepoints_expected trk
2024-10-23 22:37:29 +00:00
_ -> Expect.fail "not ok"
2024-10-23 22:37:29 +00:00
]