diff --git a/elm.json b/elm.json index 0e317c3..c39ab40 100644 --- a/elm.json +++ b/elm.json @@ -23,7 +23,9 @@ } }, "test-dependencies": { - "direct": {}, + "direct": { + "elm-explorations/test": "2.1.2" + }, "indirect": {} } } diff --git a/src/PhotoGroove.elm b/src/PhotoGroove.elm index f666301..6b7ec49 100644 --- a/src/PhotoGroove.elm +++ b/src/PhotoGroove.elm @@ -1,4 +1,4 @@ -port module PhotoGroove exposing (main) +port module PhotoGroove exposing (main, photoDecoder) import Browser import Html exposing (Attribute, Html, button, canvas, div, h1, h3, img, input, label, node, text) diff --git a/tests/PhotoGrooveTest.elm b/tests/PhotoGrooveTest.elm new file mode 100644 index 0000000..55faa5b --- /dev/null +++ b/tests/PhotoGrooveTest.elm @@ -0,0 +1,19 @@ +module PhotoGrooveTest exposing (..) + +import Expect exposing (Expectation) +import Fuzz exposing (Fuzzer, int, list, string) +import Json.Decode as J +import PhotoGroove as Testee +import Test exposing (..) + + +suite : Test +suite = + describe "photoDecoder" + [ test "title defaults to '(untitled)'" <| + \_ -> + """{"url": "example.com", "size": 5}""" + |> J.decodeString Testee.photoDecoder + |> Result.map (\p -> p.title) + |> Expect.equal (Ok "(untitled)") + ]