diff options
author | 2024-03-28 09:17:53 +0100 | |
---|---|---|
committer | 2024-03-28 09:17:53 +0100 | |
commit | 8ef3050f1461bb824f095af5157624bfb68ef63c (patch) | |
tree | fa14f03b307c4fea4218f89ce75fceea48790a81 /packages/integrations/cloudflare/test/astro-dev-platform.test.js | |
parent | 08f6167c012a2c61da5055f350acdf62a8b12b8f (diff) | |
download | astro-8ef3050f1461bb824f095af5157624bfb68ef63c.tar.gz astro-8ef3050f1461bb824f095af5157624bfb68ef63c.tar.zst astro-8ef3050f1461bb824f095af5157624bfb68ef63c.zip |
feat(cloudflare): major refactor for v10 (#159)
Co-authored-by: Matthew Phillips <361671+matthewp@users.noreply.github.com>
Co-authored-by: Emanuele Stoppa <602478+ematipico@users.noreply.github.com>
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Diffstat (limited to 'packages/integrations/cloudflare/test/astro-dev-platform.test.js')
-rw-r--r-- | packages/integrations/cloudflare/test/astro-dev-platform.test.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/packages/integrations/cloudflare/test/astro-dev-platform.test.js b/packages/integrations/cloudflare/test/astro-dev-platform.test.js new file mode 100644 index 000000000..f360b93a7 --- /dev/null +++ b/packages/integrations/cloudflare/test/astro-dev-platform.test.js @@ -0,0 +1,72 @@ +import * as assert from 'node:assert/strict'; +import { after, before, describe, it } from 'node:test'; +import { fileURLToPath } from 'node:url'; +import * as cheerio from 'cheerio'; +import { astroCli } from './_test-utils.js'; + +const root = new URL('./fixtures/astro-dev-platform/', import.meta.url); +describe('AstroDevPlatform', () => { + 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(); + }); + + it('exists', async () => { + const res = await fetch('http://127.0.0.1:4321/'); + const html = await res.text(); + const $ = cheerio.load(html); + assert.equal($('#hasRuntime').text().includes('true'), true); + }); + + it('adds cf object', async () => { + const res = await fetch('http://127.0.0.1:4321/'); + const html = await res.text(); + const $ = cheerio.load(html); + assert.equal($('#hasCF').text(), 'true'); + }); + + it('adds cache mocking', async () => { + const res = await fetch('http://127.0.0.1:4321/caches'); + const html = await res.text(); + const $ = cheerio.load(html); + assert.equal($('#hasCACHE').text(), 'true'); + }); + + it('adds D1 mocking', async () => { + const res = await fetch('http://127.0.0.1:4321/d1'); + const html = await res.text(); + const $ = cheerio.load(html); + assert.equal($('#hasDB').text(), 'true'); + assert.equal($('#hasPRODDB').text(), 'true'); + assert.equal($('#hasACCESS').text(), 'true'); + }); + + it('adds R2 mocking', async () => { + const res = await fetch('http://127.0.0.1:4321/r2'); + const html = await res.text(); + const $ = cheerio.load(html); + assert.equal($('#hasBUCKET').text(), 'true'); + assert.equal($('#hasPRODBUCKET').text(), 'true'); + assert.equal($('#hasACCESS').text(), 'true'); + }); + + it('adds KV mocking', async () => { + const res = await fetch('http://127.0.0.1:4321/kv'); + const html = await res.text(); + const $ = cheerio.load(html); + assert.equal($('#hasKV').text(), 'true'); + assert.equal($('#hasPRODKV').text(), 'true'); + assert.equal($('#hasACCESS').text(), 'true'); + }); +}); |