diff options
author | 2023-10-13 09:53:40 +0200 | |
---|---|---|
committer | 2023-10-16 16:24:07 +0200 | |
commit | 5ce6ac0b7d2bdc44f4c5083a8e8457892dcdf64d (patch) | |
tree | 62b86aecf8b27e9c1a6969acc6068b95a49c4bd3 /packages/integrations/cloudflare/test/dev-runtime.test.js | |
parent | 2c5fc57322ee42bb505aca72cd9b2e27b273b7eb (diff) | |
download | astro-5ce6ac0b7d2bdc44f4c5083a8e8457892dcdf64d.tar.gz astro-5ce6ac0b7d2bdc44f4c5083a8e8457892dcdf64d.tar.zst astro-5ce6ac0b7d2bdc44f4c5083a8e8457892dcdf64d.zip |
chore(cloudflare): fixup migration issues
Diffstat (limited to 'packages/integrations/cloudflare/test/dev-runtime.test.js')
-rw-r--r-- | packages/integrations/cloudflare/test/dev-runtime.test.js | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/packages/integrations/cloudflare/test/dev-runtime.test.js b/packages/integrations/cloudflare/test/dev-runtime.test.js new file mode 100644 index 000000000..45bd5474d --- /dev/null +++ b/packages/integrations/cloudflare/test/dev-runtime.test.js @@ -0,0 +1,82 @@ +import { expect } from "chai"; +import * as cheerio from "cheerio"; +import { fileURLToPath } from "node:url"; +import { astroCli } from "./_test-utils.js"; + +const root = new URL("./fixtures/dev-runtime/", import.meta.url); +describe("Runtime Astro Dev", () => { + let cli; + before(async () => { + cli = astroCli(fileURLToPath(root), "dev", "--host", "127.0.0.1"); + await new Promise((resolve) => { + cli.stdout.on("data", (data) => { + if (data.includes("http://127.0.0.1:4321/")) { + resolve(); + } + }); + }); + }); + + after((done) => { + cli.kill(); + setTimeout(() => { + console.log("CLEANED"); + done(); + }, 1000); + }); + + it("exists", async () => { + let res = await fetch(`http://127.0.0.1:4321/`); + let html = await res.text(); + let $ = cheerio.load(html); + expect($("#hasRuntime").text()).to.contain("true"); + }); + + it("adds cf object", async () => { + let res = await fetch(`http://127.0.0.1:4321/`); + let html = await res.text(); + let $ = cheerio.load(html); + expect($("#hasCF").text()).to.equal("true"); + }); + + it("adds cache mocking", async () => { + let res = await fetch(`http://127.0.0.1:4321/caches`); + let html = await res.text(); + let $ = cheerio.load(html); + expect($("#hasCACHE").text()).to.equal("true"); + }); + + it("adds D1 mocking", async () => { + let res = await fetch(`http://127.0.0.1:4321/d1`); + let html = await res.text(); + let $ = cheerio.load(html); + expect($("#hasDB").text()).to.equal("true"); + expect($("#hasPRODDB").text()).to.equal("true"); + expect($("#hasACCESS").text()).to.equal("true"); + }); + + it("adds R2 mocking", async () => { + let res = await fetch(`http://127.0.0.1:4321/r2`); + let html = await res.text(); + let $ = cheerio.load(html); + expect($("#hasBUCKET").text()).to.equal("true"); + expect($("#hasPRODBUCKET").text()).to.equal("true"); + expect($("#hasACCESS").text()).to.equal("true"); + }); + + it("adds KV mocking", async () => { + let res = await fetch(`http://127.0.0.1:4321/kv`); + let html = await res.text(); + let $ = cheerio.load(html); + expect($("#hasKV").text()).to.equal("true"); + expect($("#hasPRODKV").text()).to.equal("true"); + expect($("#hasACCESS").text()).to.equal("true"); + }); + + it("adds DO mocking", async () => { + let res = await fetch(`http://127.0.0.1:4321/do`); + let html = await res.text(); + let $ = cheerio.load(html); + expect($("#hasDO").text()).to.equal("true"); + }); +}); |