From c192195a71c23791c5973ace0817cb697131a9d5 Mon Sep 17 00:00:00 2001 From: aabccd021 Date: Thu, 5 Dec 2024 14:06:39 +0700 Subject: [PATCH] 1. Fix: Update file import and headers formatting 2. Refactor: Add missing comma and change quotes for consistency 3. Refactor: Add missing comma for better syntax consistency 4. Fix: Add missing comma for syntax correctness 5. Refactor: Change quotes for consistency and clarity 6. Fix: Add missing comma in spawn options 7. Fix: Add missing comma in spawn options 8. Fix: Add missing comma in process arrow function 9. Fix: Correct page URL to use consistent quotes 10. Fix: Change quoting for page innerText comparison 11. Refactor: Change quoting for page innerText comparison 12. Refactor: Change quoting for text replacement 13. Refactor: Change quoting in text replacement 14. Refactor: Change quoting for waitForEvent parameter 15. Refactor: Change quoting for waitForEvent parameter --- example.ts | 6 +++--- test/reloads.ts | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/example.ts b/example.ts index 3e27bb1..28851e2 100644 --- a/example.ts +++ b/example.ts @@ -1,9 +1,9 @@ -import { withHtmlLiveReload } from './index.ts'; +import { withHtmlLiveReload } from "./index.ts"; Bun.serve({ fetch: withHtmlLiveReload(async () => { return new Response("
Init
", { - headers: { "Content-Type": "text/html", }, + headers: { "Content-Type": "text/html" }, }); - }) + }), }); diff --git a/test/reloads.ts b/test/reloads.ts index a3b358c..30232ab 100644 --- a/test/reloads.ts +++ b/test/reloads.ts @@ -7,33 +7,34 @@ const tmpdir = fs.mkdtempSync(`${systemTmp}/bun-`); fs.copyFileSync(`${import.meta.dir}/../example.ts`, `${tmpdir}/example.ts`); fs.copyFileSync(`${import.meta.dir}/../index.ts`, `${tmpdir}/index.ts`); - -const child = Bun.spawn(["bun", "--hot", `${tmpdir}/example.ts`], { stderr: "ignore" }) +const child = Bun.spawn(["bun", "--hot", `${tmpdir}/example.ts`], { + stderr: "ignore", +}); process.on("exit", async () => { child?.kill(); await browser.close(); -}) +}); const browser = await chromium.launch(); const context = await browser.newContext(); const page = await context.newPage(); -await page.goto('http://localhost:3000'); +await page.goto("http://localhost:3000"); -const name = await page.innerText('div'); -if (name !== 'Init') { +const name = await page.innerText("div"); +if (name !== "Init") { throw new Error(`Unexpected content ${name}`); } const text = await Bun.file(`${tmpdir}/example.ts`).text(); -const newText = text.replace('Init', 'Changed'); +const newText = text.replace("Init", "Changed"); await Bun.write(`${tmpdir}/example.ts`, newText); -await page.waitForEvent('framenavigated'); +await page.waitForEvent("framenavigated"); -const newName = await page.innerText('div'); -if (newName !== 'Changed') { +const newName = await page.innerText("div"); +if (newName !== "Changed") { throw new Error(`Unexpected content: ${newName}`); }