2020-09-21 21:26:41 +09:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-03-14 21:43:49 +01:00
|
|
|
import { assertEquals } from "../testing/asserts.ts";
|
2020-09-27 06:22:32 -04:00
|
|
|
import { parse, stringify } from "./querystring.ts";
|
2020-03-14 21:43:49 +01:00
|
|
|
|
2020-06-12 20:23:38 +01:00
|
|
|
Deno.test({
|
2020-03-14 21:43:49 +01:00
|
|
|
name: "stringify",
|
|
|
|
fn() {
|
|
|
|
assertEquals(
|
|
|
|
stringify({
|
|
|
|
a: "hello",
|
|
|
|
b: 5,
|
|
|
|
c: true,
|
2020-03-29 04:03:49 +11:00
|
|
|
d: ["foo", "bar"],
|
2020-03-14 21:43:49 +01:00
|
|
|
}),
|
2020-07-14 15:24:17 -04:00
|
|
|
"a=hello&b=5&c=true&d=foo&d=bar",
|
2020-03-14 21:43:49 +01:00
|
|
|
);
|
2020-03-29 04:03:49 +11:00
|
|
|
},
|
2020-03-14 21:43:49 +01:00
|
|
|
});
|
|
|
|
|
2020-06-12 20:23:38 +01:00
|
|
|
Deno.test({
|
2020-03-14 21:43:49 +01:00
|
|
|
name: "parse",
|
|
|
|
fn() {
|
|
|
|
assertEquals(parse("a=hello&b=5&c=true&d=foo&d=bar"), {
|
|
|
|
a: "hello",
|
|
|
|
b: "5",
|
|
|
|
c: "true",
|
2020-03-29 04:03:49 +11:00
|
|
|
d: ["foo", "bar"],
|
2020-03-14 21:43:49 +01:00
|
|
|
});
|
2020-03-29 04:03:49 +11:00
|
|
|
},
|
2020-03-14 21:43:49 +01:00
|
|
|
});
|