0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/integrations/cloudflare/test/cf.test.js
Alexander Niebuhr ffcfcddb75
feat(@astrojs/cloudfalre): add cloudflare envs to Astro.locals (#7541)
* add support for advanced mode

* add support for directory mode

* use asset fallback as in cloudflare's docs

* update locals

* come up with new runtime in `Astro.locals`

* add overwrite protection

* minor cleanup

* changeset

* address review comments

* move overwrite protection to adapter

* fix types

* fix comment

* resolve review comments

* update changeset

* add test

* redo ts

* fix integration test port

* updated tests, add new port

* add TODO comment

* update changeset

* add JSDoc

* Update packages/integrations/cloudflare/src/runtime.ts

---------

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
2023-08-10 10:19:00 -05:00

37 lines
967 B
JavaScript

import { loadFixture, runCLI } from './test-utils.js';
import { expect } from 'chai';
import * as cheerio from 'cheerio';
import cloudflare from '../dist/index.js';
describe('Cf metadata and caches', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
/** @type {import('./test-utils').WranglerCLI} */
let cli;
before(async () => {
fixture = await loadFixture({
root: './fixtures/cf/',
output: 'server',
adapter: cloudflare(),
});
await fixture.build();
cli = runCLI('./fixtures/cf/', { silent: false, port: 8788 });
await cli.ready;
});
after(async () => {
await cli.stop();
});
it('Load cf and caches API', async () => {
let res = await fetch(`http://localhost:8788/`);
expect(res.status).to.equal(200);
let html = await res.text();
let $ = cheerio.load(html);
// console.log($('#cf').text(), html);
expect($('#cf').text()).to.contain('city');
expect($('#hasCache').text()).to.equal('true');
});
});