well-known-locations.test.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import * as assert from 'node:assert/strict';
  2. import { describe, it, before, after } from 'node:test';
  3. import nodejs from '../dist/index.js';
  4. import { loadFixture } from './test-utils.js';
  5. describe('test URIs beginning with a dot', () => {
  6. /** @type {import('./test-utils').Fixture} */
  7. let fixture;
  8. before(async () => {
  9. fixture = await loadFixture({
  10. root: './fixtures/well-known-locations/',
  11. output: 'server',
  12. adapter: nodejs({ mode: 'standalone' }),
  13. });
  14. await fixture.build();
  15. });
  16. describe('can load well-known URIs', async () => {
  17. let devPreview;
  18. before(async () => {
  19. devPreview = await fixture.preview();
  20. });
  21. after(async () => {
  22. await devPreview.stop();
  23. });
  24. it('can load a valid well-known URI', async () => {
  25. const res = await fixture.fetch('/.well-known/apple-app-site-association');
  26. assert.equal(res.status, 200);
  27. const json = await res.json();
  28. assert.notEqual(json.applinks, {});
  29. });
  30. it('cannot load a dot folder that is not a well-known URI', async () => {
  31. const res = await fixture.fetch('/.hidden/file.json');
  32. assert.equal(res.status, 404);
  33. });
  34. });
  35. });