Created
May 28, 2016 21:12
-
-
Save manuscrypt/48a1408c8d5ad5611682fb439cb63c50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Tests exposing (..) | |
import Tweet exposing (..) | |
import Html exposing (..) | |
import Json.Encode as Encode | |
import Random exposing (Generator) | |
import Shrink | |
import Check exposing (..) | |
import Check.Test | |
import Check.Producer exposing (..) | |
import ElmTest | |
toJson : Int -> String -> String | |
toJson id txt = | |
[ ("id", Encode.int id) | |
, ("id_str", Encode.string (toString id)) | |
, ("text", Encode.string txt) | |
] |> Encode.object |> Encode.encode 0 | |
myClaims : Claim | |
myClaims = | |
suite "Tweet Decoding" | |
[ Check.claim | |
"Decoding string containing proper tweet-JSON yields Tweet" | |
`that` | |
(\(id, txt) -> Tweet.decode <| toJson id txt ) | |
`is` | |
(\(id, txt) -> Just (Tweet.Model id (toString id) txt)) | |
`for` | |
producer | |
] | |
producer : Producer (Int,String) | |
producer = Producer generator Shrink.noShrink | |
generator : Generator (Int, String) | |
generator = Random.pair (Random.int 100 100000) string.generator | |
evidence : Evidence | |
evidence = quickCheck myClaims | |
main : Html a | |
main = | |
div [] [text <| ElmTest.consoleRunner (Check.Test.evidenceToTest evidence)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note: this is certainly not how you run tests