diff options
Diffstat (limited to 'test/js')
| -rw-r--r-- | test/js/web/fetch/fetch.test.ts | 10 | ||||
| -rw-r--r-- | test/js/web/fetch/file with space in the name.txt | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/test/js/web/fetch/fetch.test.ts b/test/js/web/fetch/fetch.test.ts index 768818420..d7fc87ade 100644 --- a/test/js/web/fetch/fetch.test.ts +++ b/test/js/web/fetch/fetch.test.ts @@ -1203,3 +1203,13 @@ it("new Request(https://example.com, otherRequest) uses url from left instead of expect(req2.url).toBe("http://localhost/def"); expect(req2.headers.get("foo")).toBe("bar"); }); + +it("fetch() file:// works", async () => { + expect(await (await fetch(import.meta.url)).text()).toEqual(await Bun.file(import.meta.path).text()); + expect(await (await fetch(new URL("fetch.test.ts", import.meta.url))).text()).toEqual( + await Bun.file(Bun.fileURLToPath(new URL("fetch.test.ts", import.meta.url))).text(), + ); + expect(await (await fetch(new URL("file with space in the name.txt", import.meta.url))).text()).toEqual( + await Bun.file(Bun.fileURLToPath(new URL("file with space in the name.txt", import.meta.url))).text(), + ); +}); diff --git a/test/js/web/fetch/file with space in the name.txt b/test/js/web/fetch/file with space in the name.txt new file mode 100644 index 000000000..3462721fd --- /dev/null +++ b/test/js/web/fetch/file with space in the name.txt @@ -0,0 +1 @@ +hello!
\ No newline at end of file |
