diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/gleam_json_test.gleam | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/test/gleam_json_test.gleam b/test/gleam_json_test.gleam index 162fa6e..768a994 100644 --- a/test/gleam_json_test.gleam +++ b/test/gleam_json_test.gleam @@ -1,9 +1,9 @@ import gleam/dynamic +import gleam/json import gleam/option.{None, Some} import gleam/result -import gleam/json -import gleeunit/should import gleeunit +import gleeunit/should pub fn main() { gleeunit.main() @@ -19,24 +19,30 @@ pub fn decode_test() { |> should.equal(Error(Nil)) } -pub fn encode_test() { +pub fn encode_string_test() { json.string("hello") - |> json.encode() + |> json.to_string() |> should.equal("\"hello\"") +} +pub fn encode_null_test() { json.null() - |> json.encode() + |> json.to_string() |> should.equal("null") +} +pub fn encode_object_test() { json.object([#("foo", json.int(5))]) - |> json.encode() + |> json.to_string() |> should.equal("{\"foo\":5}") +} +pub fn encode_nullable_test() { json.nullable(Some(5), json.int) - |> json.encode() + |> json.to_string() |> should.equal("5") json.nullable(None, json.int) - |> json.encode() + |> json.to_string() |> should.equal("null") } |