diff options
Diffstat (limited to 'tests/unit_node/querystring_test.ts')
-rw-r--r-- | tests/unit_node/querystring_test.ts | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/unit_node/querystring_test.ts b/tests/unit_node/querystring_test.ts new file mode 100644 index 000000000..9831d92ed --- /dev/null +++ b/tests/unit_node/querystring_test.ts @@ -0,0 +1,51 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +import { assertEquals } from "@test_util/std/assert/mod.ts"; +import { parse, stringify } from "node:querystring"; + +Deno.test({ + name: "stringify", + fn() { + assertEquals( + stringify({ + a: "hello", + b: 5, + c: true, + d: ["foo", "bar"], + }), + "a=hello&b=5&c=true&d=foo&d=bar", + ); + }, +}); + +Deno.test({ + name: "parse", + fn() { + assertEquals(parse("a=hello&b=5&c=true&d=foo&d=bar"), { + a: "hello", + b: "5", + c: "true", + d: ["foo", "bar"], + }); + }, +}); + +// https://github.com/denoland/deno/issues/21734 +Deno.test({ + name: "stringify options no encode", + fn() { + assertEquals( + stringify( + { + a: "hello", + b: 5, + c: true, + d: ["foo", "bar"], + }, + "&", + "=", + {}, + ), + "a=hello&b=5&c=true&d=foo&d=bar", + ); + }, +}); |