aboutsummaryrefslogtreecommitdiff
path: root/packages/integrations/cloudflare/test/wrangler-preview-platform.test.js
diff options
context:
space:
mode:
authorGravatar Alexander Niebuhr <alexander@nbhr.io> 2024-03-28 09:17:53 +0100
committerGravatar GitHub <noreply@github.com> 2024-03-28 09:17:53 +0100
commit8ef3050f1461bb824f095af5157624bfb68ef63c (patch)
treefa14f03b307c4fea4218f89ce75fceea48790a81 /packages/integrations/cloudflare/test/wrangler-preview-platform.test.js
parent08f6167c012a2c61da5055f350acdf62a8b12b8f (diff)
downloadastro-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/wrangler-preview-platform.test.js')
-rw-r--r--packages/integrations/cloudflare/test/wrangler-preview-platform.test.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/packages/integrations/cloudflare/test/wrangler-preview-platform.test.js b/packages/integrations/cloudflare/test/wrangler-preview-platform.test.js
new file mode 100644
index 000000000..a6a04892c
--- /dev/null
+++ b/packages/integrations/cloudflare/test/wrangler-preview-platform.test.js
@@ -0,0 +1,58 @@
+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, wranglerCli } from './_test-utils.js';
+
+const root = new URL('./fixtures/wrangler-preview-platform/', import.meta.url);
+
+describe('WranglerPreviewPlatform', () => {
+ let wrangler;
+
+ before(async () => {
+ await astroCli(fileURLToPath(root), 'build');
+
+ wrangler = wranglerCli(fileURLToPath(root));
+ await new Promise((resolve) => {
+ wrangler.stdout.on('data', (data) => {
+ // console.log('[stdout]', data.toString());
+ if (data.toString().includes('http://127.0.0.1:8788')) resolve();
+ });
+ wrangler.stderr.on('data', (data) => {
+ // console.log('[stderr]', data.toString());
+ });
+ });
+ });
+
+ after((done) => {
+ wrangler.kill();
+ });
+
+ it('exists', async () => {
+ const res = await fetch('http://127.0.0.1:8788/');
+ const html = await res.text();
+ const $ = cheerio.load(html);
+ assert.equal($('#hasRuntime').text().includes('true'), true);
+ });
+
+ it('has environment variables', async () => {
+ const res = await fetch('http://127.0.0.1:8788/');
+ const html = await res.text();
+ const $ = cheerio.load(html);
+ assert.equal($('#hasENV').text().includes('true'), true);
+ });
+
+ it('has Cloudflare request object', async () => {
+ const res = await fetch('http://127.0.0.1:8788/');
+ const html = await res.text();
+ const $ = cheerio.load(html);
+ assert.equal($('#hasCF').text().includes('true'), true);
+ });
+
+ it('has Cloudflare cache', async () => {
+ const res = await fetch('http://127.0.0.1:8788/');
+ const html = await res.text();
+ const $ = cheerio.load(html);
+ assert.equal($('#hasCACHES').text().includes('true'), true);
+ });
+});