forked from dillonkearns/elm-graphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEncodeTests.elm
47 lines (42 loc) · 1.5 KB
/
EncodeTests.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
module EncodeTests exposing (all)
import Expect
import Graphql.Internal.Encode
import Test exposing (Test, describe, test)
all : Test
all =
describe "encode"
[ test "string" <|
\() ->
Graphql.Internal.Encode.string "hello"
|> Graphql.Internal.Encode.serialize
|> Expect.equal "\"hello\""
, test "boolean" <|
\() ->
Graphql.Internal.Encode.bool False
|> Graphql.Internal.Encode.serialize
|> Expect.equal "false"
, test "int" <|
\() ->
Graphql.Internal.Encode.int 123
|> Graphql.Internal.Encode.serialize
|> Expect.equal "123"
, test "empty object" <|
\() ->
Graphql.Internal.Encode.object
[]
|> Graphql.Internal.Encode.serialize
|> Expect.equal """{}"""
, test "non-empty object" <|
\() ->
Graphql.Internal.Encode.object
[ ( "number", Graphql.Internal.Encode.int 47 )
, ( "boolean", Graphql.Internal.Encode.bool True )
, ( "enum", Graphql.Internal.Encode.enum Debug.toString EMPIRE )
]
|> Graphql.Internal.Encode.serialize
|> Expect.equal """{number: 47, boolean: true, enum: EMPIRE}"""
]
type Episode
= EMPIRE
| JEDI
| NEWHOPE