aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/url.test.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-22 23:21:48 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-06-22 23:21:48 -0700
commit729d445b6885f69dd2c6355f38707bd42851c791 (patch)
treef87a7c408929ea3f57bbb7ace380cf869da83c0e /test/bun.js/url.test.ts
parent25f820c6bf1d8ec6d444ef579cc036b8c0607b75 (diff)
downloadbun-jarred/rename.tar.gz
bun-jarred/rename.tar.zst
bun-jarred/rename.zip
change the directory structurejarred/rename
Diffstat (limited to 'test/bun.js/url.test.ts')
-rw-r--r--test/bun.js/url.test.ts102
1 files changed, 102 insertions, 0 deletions
diff --git a/test/bun.js/url.test.ts b/test/bun.js/url.test.ts
new file mode 100644
index 000000000..37ea2008b
--- /dev/null
+++ b/test/bun.js/url.test.ts
@@ -0,0 +1,102 @@
+import { describe, it, expect } from "bun:test";
+
+describe("url", () => {
+ it("prints", () => {
+ expect(Bun.inspect(new URL("https://example.com"))).toBe(
+ "https://example.com/"
+ );
+
+ expect(
+ Bun.inspect(
+ new URL(
+ "https://github.com/Jarred-Sumner/bun/issues/135?hello%20i%20have%20spaces%20thank%20you%20good%20night"
+ )
+ )
+ ).toBe(
+ "https://github.com/Jarred-Sumner/bun/issues/135?hello%20i%20have%20spaces%20thank%20you%20good%20night"
+ );
+ });
+ it("works", () => {
+ const inputs: [
+ [
+ string,
+ {
+ hash: string;
+ host: string;
+ hostname: string;
+ href: string;
+ origin: string;
+ password: string;
+ pathname: string;
+ port: string;
+ protocol: string;
+ search: string;
+ username: string;
+ }
+ ]
+ ] = [
+ [
+ "https://username:password@api.foo.bar.com:9999/baz/okay/i/123?ran=out&of=things#to-use-as-a-placeholder",
+ {
+ hash: "#to-use-as-a-placeholder",
+ host: "api.foo.bar.com:9999",
+ hostname: "api.foo.bar.com",
+ href: "https://username:password@api.foo.bar.com:9999/baz/okay/i/123?ran=out&of=things#to-use-as-a-placeholder",
+ origin: "https://api.foo.bar.com:9999",
+ password: "password",
+ pathname: "/baz/okay/i/123",
+ port: "9999",
+ protocol: "https:",
+ search: "?ran=out&of=things",
+ username: "username",
+ },
+ ],
+ [
+ "https://url.spec.whatwg.org/#url-serializing",
+ {
+ hash: "#url-serializing",
+ host: "url.spec.whatwg.org",
+ hostname: "url.spec.whatwg.org",
+ href: "https://url.spec.whatwg.org/#url-serializing",
+ origin: "https://url.spec.whatwg.org",
+ password: "",
+ pathname: "/",
+ port: "",
+ protocol: "https:",
+ search: "",
+ username: "",
+ },
+ ],
+ [
+ "https://url.spec.whatwg.org#url-serializing",
+ {
+ hash: "#url-serializing",
+ host: "url.spec.whatwg.org",
+ hostname: "url.spec.whatwg.org",
+ href: "https://url.spec.whatwg.org/#url-serializing",
+ origin: "https://url.spec.whatwg.org",
+ password: "",
+ pathname: "/",
+ port: "",
+ protocol: "https:",
+ search: "",
+ username: "",
+ },
+ ],
+ ];
+
+ for (let [url, values] of inputs) {
+ const result = new URL(url);
+ expect(result.hash).toBe(values.hash);
+ expect(result.host).toBe(values.host);
+ expect(result.hostname).toBe(values.hostname);
+ expect(result.href).toBe(values.href);
+ expect(result.password).toBe(values.password);
+ expect(result.pathname).toBe(values.pathname);
+ expect(result.port).toBe(values.port);
+ expect(result.protocol).toBe(values.protocol);
+ expect(result.search).toBe(values.search);
+ expect(result.username).toBe(values.username);
+ }
+ });
+});
id=ae5e2f5af20bed319403c262f5f86620e7e27b5a&follow=1'>Update io_linux.zigGravatar Jarred Sumner 1-1/+1 2021-12-30Update io_linux.zigGravatar Jarred Sumner 1-1/+1 2021-12-30_ => .Gravatar Jarred Sumner 3-5/+5 2021-12-30- => .Gravatar Jarred Sumner 4-6/+6 2021-12-30Update bun.lockbGravatar Jarred Sumner 1-0/+0 2021-12-30Remove network_threadGravatar Jarred Sumner 1-12/+11 2021-12-30linuxGravatar Jarred Sumner 2-6/+7 2021-12-30[internal] Move network_thread into http packageGravatar Jarred Sumner 17-435/+32 2021-12-30Upgrade to latest Zig, remove dependency on patched version of Zig (#96)Gravatar Jarred Sumner 154-6271/+4561 2021-12-29zig fmtGravatar Jarred Sumner 5-8/+3 2021-12-29Update MakefileGravatar Jarred Sumner 1-1/+0