import { file, serve } from "bun"; import { expect, it } from "bun:test"; import { readFileSync } from "fs"; import { resolve } from "path"; var port = 60000; it("should work for a hello world", async () => { const server = serve({ port: port++, fetch(req) { return new Response(`Hello, world!`); }, }); const response = await fetch(`http://localhost:${server.port}`); expect(await response.text()).toBe("Hello, world!"); server.stop(); }); it("should work for a file", async () => { const fixture = resolve(import.meta.dir, "./fetch.js.txt"); const textToExpect = readFileSync(fixture, "utf-8"); const server = serve({ port: port++, fetch(req) { return new Response(file(fixture)); }, }); const response = await fetch(`http://localhost:${server.port}`); expect(await response.text()).toBe(textToExpect); server.stop(); }); // var count = 200; // it(`should work for a file ${count} times`, async () => { // const fixture = resolve(import.meta.dir, "./fetch.js.txt"); // const textToExpect = readFileSync(fixture, "utf-8"); // var ran = 0; // const server = serve({ // port: port++, // async fetch(req) { // console.log(`Ran ${ran++}`); // return new Response(file(fixture)); // }, // }); // for (let i = 0; i < count; i++) { // const response = await fetch(`http://localhost:${server.port}`); // expect(await response.text()).toBe(textToExpect); // } // server.stop(); // }); n value='bundle-all-deps'>bundle-all-deps Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/.github/workflows (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2021-05-12[wip] Fix CI (#202)Gravatar Drew Powers 4-46/+43
2021-05-11VS Code extension (#197)Gravatar Matthew Phillips 7-20/+182
2021-05-11Fix workflows! (#198)Gravatar Nate Moore 3-2/+4
2021-05-11Add Astro.request.canonicalURL and Astro.site to global (#199)Gravatar Drew Powers 25-98/+234
2021-05-11Fix portfolio example (#196)Gravatar Drew Powers 2-3/+5
2021-05-10fix: build stuck on unhandled promise reject (#191)Gravatar Kevin (Kun) "Kassimo" Qian 2-2/+13
2021-05-10Allow default import component to be renamed based on import statement defaul...Gravatar Kevin (Kun) "Kassimo" Qian 3-8/+30
2021-05-08Add more docs on styling (#186)Gravatar Drew Powers 1-3/+321
2021-05-08Fix running the extension (#181)Gravatar Matthew Phillips 5-11/+37