diff --git a/src/Track.elm b/src/Track.elm index 3bcb60a..708ef0d 100644 --- a/src/Track.elm +++ b/src/Track.elm @@ -2,7 +2,7 @@ module Track exposing (Track, Point, parse) import Result import Xml.Decode as XD exposing (path, list, single, floatAttr, stringAttr) -import Time -- exposing (utc, toHour, toMinute, toSecond) +import Time import Iso8601 type alias Point = diff --git a/tests/Fixtures.elm b/tests/Fixtures.elm index f89f843..84b537d 100644 --- a/tests/Fixtures.elm +++ b/tests/Fixtures.elm @@ -1,4 +1,7 @@ -module Fixtures exposing (threepoints) +module Fixtures exposing (threepoints, threepoints_expected) +import Track exposing (Track, Point) +import Time + threepoints = """ @@ -43,6 +46,7 @@ xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/ 1,485.96 + 66.2 @@ -58,3 +62,9 @@ xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/ """ + +threepoints_expected = + [ (Point 51.600643 -0.01856 64.8 (Time.millisToPosix 1729669252256)) + , (Point 51.600679 -0.018179 65.5 (Time.millisToPosix 1729669255259)) + , (Point 51.600697 -0.018064 66.2 (Time.millisToPosix 1729669256231)) + ] diff --git a/tests/TrackTest.elm b/tests/TrackTest.elm index a8be878..6135e54 100644 --- a/tests/TrackTest.elm +++ b/tests/TrackTest.elm @@ -4,23 +4,25 @@ import Fixtures import Track exposing (Track, Point) import Test exposing (..) import Expect exposing (Expectation) -import Time specs: Test specs = describe "XML Parsing" - [ test "it runs" <| + [ test "it parses points" <| + \_ -> + case Track.parse Fixtures.threepoints of + (Ok trk) -> Expect.equalLists Fixtures.threepoints_expected trk + _ -> Expect.fail "not ok" + , test "multiple trksegs are coalesced" <| \_ -> let - r = Track.parse Fixtures.threepoints - expected = - [ (Point 51.600643 -0.01856 64.8 (Time.millisToPosix 1729669252256)) - , (Point 51.600679 -0.018179 65.5 (Time.millisToPosix 1729669255259)) - , (Point 51.600697 -0.018064 66.2 (Time.millisToPosix 1729669256231)) - ] - + xml = String.replace + "" + "" + Fixtures.threepoints in - case r of - (Ok trk) -> Expect.equalLists expected trk + case Track.parse xml of + (Ok trk) -> Expect.equalLists Fixtures.threepoints_expected trk _ -> Expect.fail "not ok" + ]