aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKero van Gelder <kero@chmeee.org>2024-02-25 12:53:29 +0100
committerLouis Pilfold <louis@lpil.uk>2024-02-26 19:45:25 +0000
commit5be28f87ff0eeb441e943776e7f1808e8f4492d1 (patch)
treee7cf7bcbb86aa86b97a6090e0de3a123bda9ac90 /test
parentdc1d1953828e5a6d134522f97268f88b07df31be (diff)
downloadgleam_stdlib-5be28f87ff0eeb441e943776e7f1808e8f4492d1.tar.gz
gleam_stdlib-5be28f87ff0eeb441e943776e7f1808e8f4492d1.zip
Fix: do not crash w/ TypeError when field decodes a null object (possibly obtained via JSON)
Diffstat (limited to 'test')
-rw-r--r--test/gleam/dynamic_test.gleam10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/gleam/dynamic_test.gleam b/test/gleam/dynamic_test.gleam
index 4b6fc53..2e36777 100644
--- a/test/gleam/dynamic_test.gleam
+++ b/test/gleam/dynamic_test.gleam
@@ -79,6 +79,16 @@ pub fn dict_from_null_test() {
)
}
+@target(javascript)
+pub fn null_for_field_test() {
+ get_null()
+ |> dynamic.from
+ |> dynamic.field("x", dynamic.string)
+ |> should.equal(
+ Error([DecodeError(expected: "Dict", found: "Null", path: [])]),
+ )
+}
+
pub fn string_test() {
""
|> dynamic.from