Through section 6.2
This commit is contained in:
parent
0c408d5362
commit
8af7b143e4
4
elm.json
4
elm.json
|
@ -23,7 +23,9 @@
|
|||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
"direct": {},
|
||||
"direct": {
|
||||
"elm-explorations/test": "2.0.1"
|
||||
},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
port module PhotoGroove exposing (main)
|
||||
port module PhotoGroove exposing (Model, Msg(..), initialModel, main, photoDecoder, update)
|
||||
|
||||
import Browser
|
||||
import Html exposing (..)
|
||||
|
|
42
tests/PhotoGrooveTests.elm
Normal file
42
tests/PhotoGrooveTests.elm
Normal file
|
@ -0,0 +1,42 @@
|
|||
module PhotoGrooveTests exposing (..)
|
||||
|
||||
import Expect exposing (Expectation)
|
||||
import Fuzz exposing (Fuzzer, int, list, string)
|
||||
import Json.Decode as Decode exposing (decodeValue)
|
||||
import Json.Encode as Encode
|
||||
import PhotoGroove exposing (Model, Msg(..), initialModel, photoDecoder, update)
|
||||
import Test exposing (..)
|
||||
|
||||
|
||||
decoderTest : Test
|
||||
decoderTest =
|
||||
fuzz2 string int "title defaults to (untitled)" <|
|
||||
\url size ->
|
||||
Encode.object
|
||||
[ ( "url", Encode.string url )
|
||||
, ( "size", Encode.int size )
|
||||
]
|
||||
|> decodeValue photoDecoder
|
||||
|> Result.map .title
|
||||
|> Expect.equal
|
||||
(Ok "(untitled)")
|
||||
|
||||
|
||||
sliders : Test
|
||||
sliders =
|
||||
describe "Slider sets the desired field in the Model"
|
||||
[ testSlider "SlidHue" SlidHue .hue
|
||||
, testSlider "SlidRipple" SlidRipple .ripple
|
||||
, testSlider "SlidNoise" SlidNoise .noise
|
||||
]
|
||||
|
||||
|
||||
testSlider : String -> (Int -> Msg) -> (Model -> Int) -> Test
|
||||
testSlider description toMsg amountFromModel =
|
||||
fuzz int description <|
|
||||
\amount ->
|
||||
initialModel
|
||||
|> update (toMsg amount)
|
||||
|> Tuple.first
|
||||
|> amountFromModel
|
||||
|> Expect.equal amount
|
Loading…
Reference in a new issue