chapter 6: Add unit-tests
This commit is contained in:
parent
43971bd268
commit
034b147740
3 changed files with 23 additions and 2 deletions
4
elm.json
4
elm.json
|
|
@ -23,7 +23,9 @@
|
|||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
"direct": {},
|
||||
"direct": {
|
||||
"elm-explorations/test": "2.1.2"
|
||||
},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
19
tests/PhotoGrooveTest.elm
Normal file
19
tests/PhotoGrooveTest.elm
Normal file
|
|
@ -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)")
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue