diff options
author | 2022-03-31 14:04:09 -0400 | |
---|---|---|
committer | 2022-03-31 14:04:09 -0400 | |
commit | cebdc85428d0ed367c049a3ef5d9b0c77d78ad2e (patch) | |
tree | baba4974463b7304859b7e6d4f39c78f74e53046 /packages/astro/test/ssr-request.test.js | |
parent | e044d99696ad344c7958ecab7314161ccc339f41 (diff) | |
download | astro-cebdc85428d0ed367c049a3ef5d9b0c77d78ad2e.tar.gz astro-cebdc85428d0ed367c049a3ef5d9b0c77d78ad2e.tar.zst astro-cebdc85428d0ed367c049a3ef5d9b0c77d78ad2e.zip |
SSR - copy public folder when there is no client JS (#2955)
* SSR - copy public folder when there is no client JS
* Changest
* Use isBuildingToSSR
Co-authored-by: JuanM04 <me@juanm04.com>
Diffstat (limited to '')
-rw-r--r-- | packages/astro/test/ssr-request.test.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/astro/test/ssr-request.test.js b/packages/astro/test/ssr-request.test.js new file mode 100644 index 000000000..30efb8ef8 --- /dev/null +++ b/packages/astro/test/ssr-request.test.js @@ -0,0 +1,36 @@ + +import { expect } from 'chai'; +import { load as cheerioLoad } from 'cheerio'; +import { loadFixture } from './test-utils.js'; +import testAdapter from './test-adapter.js'; + +// Asset bundling +describe('Using Astro.request in SSR', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + projectRoot: './fixtures/ssr-request/', + buildOptions: { + experimentalSsr: true, + }, + adapter: testAdapter(), + }); + await fixture.build(); + }); + + it('Gets the request pased in', async () => { + const app = await fixture.loadTestAdapterApp(); + const request = new Request('http://example.com/request'); + const response = await app.render(request); + const html = await response.text(); + const $ = cheerioLoad(html); + expect($('#origin').text()).to.equal('http://example.com'); + }); + + it('public file is copied over', async () => { + const json = await fixture.readFile('/client/cars.json'); + expect(json).to.not.be.undefined; + }); +}); |