From 30248f52a042fa5de08b08e79d76aa3d6a9c4eaf Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Sat, 1 Jan 2022 15:50:49 +0000 Subject: Convert to Thoas --- test/gleam_json_test.gleam | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'test') 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") } -- cgit v1.2.3