diff options
author | 2023-01-11 10:52:51 +0100 | |
---|---|---|
committer | 2023-01-11 17:52:51 +0800 | |
commit | 2303f95142aa740c99213a098f82b99dd37d74a0 (patch) | |
tree | e41cfe39b80a84a342c7a74d1bb1721f7c2376f7 /packages/integrations/node/test | |
parent | 4b16e9ec9929269a16e7950d8fed78779149b0fc (diff) | |
download | astro-2303f95142aa740c99213a098f82b99dd37d74a0.tar.gz astro-2303f95142aa740c99213a098f82b99dd37d74a0.tar.zst astro-2303f95142aa740c99213a098f82b99dd37d74a0.zip |
Add support for serving well-known URIs with the @astrojs/node SSR adapter (#5832)
Diffstat (limited to 'packages/integrations/node/test')
4 files changed, 58 insertions, 0 deletions
diff --git a/packages/integrations/node/test/fixtures/well-known-locations/package.json b/packages/integrations/node/test/fixtures/well-known-locations/package.json new file mode 100644 index 000000000..f018b6ec7 --- /dev/null +++ b/packages/integrations/node/test/fixtures/well-known-locations/package.json @@ -0,0 +1,9 @@ +{ + "name": "@test/well-known-locations", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*", + "@astrojs/node": "workspace:*" + } +} diff --git a/packages/integrations/node/test/fixtures/well-known-locations/public/.hidden/file.json b/packages/integrations/node/test/fixtures/well-known-locations/public/.hidden/file.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/packages/integrations/node/test/fixtures/well-known-locations/public/.hidden/file.json @@ -0,0 +1 @@ +{} diff --git a/packages/integrations/node/test/fixtures/well-known-locations/public/.well-known/apple-app-site-association b/packages/integrations/node/test/fixtures/well-known-locations/public/.well-known/apple-app-site-association new file mode 100644 index 000000000..daae260f1 --- /dev/null +++ b/packages/integrations/node/test/fixtures/well-known-locations/public/.well-known/apple-app-site-association @@ -0,0 +1,3 @@ +{ + "applinks": {} +} diff --git a/packages/integrations/node/test/well-known-locations.test.js b/packages/integrations/node/test/well-known-locations.test.js new file mode 100644 index 000000000..31f31bacd --- /dev/null +++ b/packages/integrations/node/test/well-known-locations.test.js @@ -0,0 +1,45 @@ +import nodejs from '../dist/index.js'; +import { loadFixture } from './test-utils.js'; +import { expect } from 'chai'; + +describe('test URIs beginning with a dot', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/well-known-locations/', + output: 'server', + adapter: nodejs({ mode: 'standalone' }), + }); + await fixture.build(); + }); + + describe('can load well-known URIs', async () => { + let devPreview; + + before(async () => { + devPreview = await fixture.preview(); + }); + + after(async () => { + await devPreview.stop(); + }); + + it('can load a valid well-known URI', async () => { + const res = await fixture.fetch('/.well-known/apple-app-site-association'); + + expect(res.status).to.equal(200); + + const json = await res.json(); + + expect(json).to.deep.equal({ applinks: {} }); + }); + + it('cannot load a dot folder that is not a well-known URI', async () => { + const res = await fixture.fetch('/.hidden/file.json'); + + expect(res.status).to.equal(404); + }); + }); +}); |