diff options
author | Louis Pilfold <louis@lpil.uk> | 2022-01-01 15:50:49 +0000 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2022-01-01 15:50:49 +0000 |
commit | 30248f52a042fa5de08b08e79d76aa3d6a9c4eaf (patch) | |
tree | 2292f01cfe136bbccf7223c7ed199c371aa02734 /test | |
parent | 87c49c3fc248ceca5557c4f873a468884a9ca14a (diff) | |
download | gleam_json-30248f52a042fa5de08b08e79d76aa3d6a9c4eaf.tar.gz gleam_json-30248f52a042fa5de08b08e79d76aa3d6a9c4eaf.zip |
Convert to Thoas
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") } |