Many updatesg
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
],
|
||||
"exposed-modules": [],
|
||||
"dependencies": {
|
||||
"NoRedInk/elm-decode-pipeline": "1.0.0 <= v < 2.0.0",
|
||||
"NoRedInk/elm-decode-pipeline": "1.1.2 <= v < 2.0.0",
|
||||
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
||||
"elm-lang/html": "1.0.0 <= v < 2.0.0",
|
||||
"evancz/elm-http": "3.0.1 <= v < 4.0.0"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module Auth (token) where
|
||||
module Auth exposing (token)
|
||||
|
||||
|
||||
token : String
|
||||
token =
|
||||
-- Tests don't need a real token.
|
||||
""
|
||||
-- Tests don't need a real token.
|
||||
""
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
module Main where
|
||||
|
||||
import Signal exposing (Signal)
|
||||
|
||||
import ElmTest exposing (consoleRunner)
|
||||
import Console exposing (IO, run)
|
||||
import Task
|
||||
|
||||
import Tests
|
||||
|
||||
console : IO ()
|
||||
console = consoleRunner Tests.all
|
||||
|
||||
port runner : Signal (Task.Task x ())
|
||||
port runner = run console
|
||||
@@ -1,51 +1,57 @@
|
||||
module Tests (..) where
|
||||
port module Main exposing (..)
|
||||
|
||||
import ElmTest exposing (..)
|
||||
import Test exposing (..)
|
||||
import Expect exposing (Expectation)
|
||||
import ElmHub exposing (responseDecoder)
|
||||
import Json.Decode exposing (decodeString)
|
||||
import Json.Decode exposing (decodeString, Value)
|
||||
import Test.Runner.Node as Runner
|
||||
|
||||
|
||||
all : Test
|
||||
all =
|
||||
suite
|
||||
"Decoding responses from GitHub"
|
||||
[ test "they can decode empty responses"
|
||||
<| let
|
||||
emptyResponse =
|
||||
"""{ "items": [] }"""
|
||||
in
|
||||
assertEqual
|
||||
(decodeString responseDecoder emptyResponse)
|
||||
(Ok [])
|
||||
, test "they can decode responses with results in them"
|
||||
<| let
|
||||
response =
|
||||
"""{ "items": [
|
||||
{ "id": 5, "full_name": "foo", "stargazers_count": 42 },
|
||||
{ "id": 3, "full_name": "bar", "stargazers_count": 77 }
|
||||
] }"""
|
||||
in
|
||||
assertEqual
|
||||
(decodeString responseDecoder response)
|
||||
(Ok
|
||||
[ { id = 5, name = "foo", stars = 42 }
|
||||
, { id = 3, name = "bar", stars = 77 }
|
||||
]
|
||||
)
|
||||
, test "they result in an error for invalid JSON"
|
||||
<| let
|
||||
response =
|
||||
"""{ "pizza": [] }"""
|
||||
main : Program Never
|
||||
main =
|
||||
describe "Decoding responses from GitHub"
|
||||
[ test "they can decode empty responses"
|
||||
<| \() ->
|
||||
let
|
||||
emptyResponse =
|
||||
"""{ "items": [] }"""
|
||||
in
|
||||
Expect.equal (Ok [])
|
||||
(decodeString responseDecoder emptyResponse)
|
||||
, test "they can decode responses with results in them"
|
||||
<| \() ->
|
||||
let
|
||||
response =
|
||||
"""{ "items": [
|
||||
{ "id": 5, "full_name": "foo", "stargazers_count": 42 },
|
||||
{ "id": 3, "full_name": "bar", "stargazers_count": 77 }
|
||||
] }"""
|
||||
in
|
||||
Expect.equal
|
||||
(Ok
|
||||
[ { id = 5, name = "foo", stars = 42 }
|
||||
, { id = 3, name = "bar", stars = 77 }
|
||||
]
|
||||
)
|
||||
(decodeString responseDecoder response)
|
||||
, test "they result in an error for invalid JSON"
|
||||
<| \() ->
|
||||
let
|
||||
response =
|
||||
"""{ "pizza": [] }"""
|
||||
|
||||
isErrorResult result =
|
||||
case result of
|
||||
Ok _ ->
|
||||
False
|
||||
isErrorResult result =
|
||||
case result of
|
||||
Ok _ ->
|
||||
False
|
||||
|
||||
Err _ ->
|
||||
True
|
||||
in
|
||||
assertEqual
|
||||
True
|
||||
(isErrorResult (decodeString responseDecoder response))
|
||||
]
|
||||
Err _ ->
|
||||
True
|
||||
in
|
||||
Expect.equal True
|
||||
(isErrorResult (decodeString responseDecoder response))
|
||||
]
|
||||
|> Runner.run emit
|
||||
|
||||
|
||||
port emit : ( String, Value ) -> Cmd msg
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
],
|
||||
"exposed-modules": [],
|
||||
"dependencies": {
|
||||
"NoRedInk/elm-decode-pipeline": "1.0.0 <= v < 2.0.0",
|
||||
"project-fuzzball/test": "2.0.1 <= v < 3.0.0",
|
||||
"project-fuzzball/node": "1.0.2 <= v < 2.0.0",
|
||||
"NoRedInk/elm-decode-pipeline": "1.1.2 <= v < 2.0.0",
|
||||
"elm-lang/core": "4.0.1 <= v < 5.0.0",
|
||||
"elm-lang/html": "1.0.0 <= v < 2.0.0",
|
||||
"evancz/elm-http": "3.0.1 <= v < 4.0.0"
|
||||
|
||||
Reference in New Issue
Block a user