From 1d5e1ea482cce77986faaee56e188779ebee014b Mon Sep 17 00:00:00 2001 From: lilnasy <69170106+lilnasy@users.noreply.github.com> Date: Wed, 3 Jan 2024 17:04:38 +0000 Subject: [PATCH] add test --- .../test/fixtures/static/astro.config.mjs | 6 +++++ .../vercel/test/fixtures/static/package.json | 9 +++++++ .../test/fixtures/static/src/pages/404.astro | 8 ++++++ .../test/fixtures/static/src/pages/one.astro | 8 ++++++ .../test/fixtures/static/src/pages/two.astro | 8 ++++++ .../integrations/vercel/test/static.test.js | 26 +++++++++++++++++++ pnpm-lock.yaml | 9 +++++++ 7 files changed, 74 insertions(+) create mode 100644 packages/integrations/vercel/test/fixtures/static/astro.config.mjs create mode 100644 packages/integrations/vercel/test/fixtures/static/package.json create mode 100644 packages/integrations/vercel/test/fixtures/static/src/pages/404.astro create mode 100644 packages/integrations/vercel/test/fixtures/static/src/pages/one.astro create mode 100644 packages/integrations/vercel/test/fixtures/static/src/pages/two.astro create mode 100644 packages/integrations/vercel/test/static.test.js diff --git a/packages/integrations/vercel/test/fixtures/static/astro.config.mjs b/packages/integrations/vercel/test/fixtures/static/astro.config.mjs new file mode 100644 index 000000000000..55620c240533 --- /dev/null +++ b/packages/integrations/vercel/test/fixtures/static/astro.config.mjs @@ -0,0 +1,6 @@ +import { defineConfig } from 'astro/config'; +import vercel from '@astrojs/vercel/static'; + +export default defineConfig({ + adapter: vercel() +}); diff --git a/packages/integrations/vercel/test/fixtures/static/package.json b/packages/integrations/vercel/test/fixtures/static/package.json new file mode 100644 index 000000000000..2f2936e31a31 --- /dev/null +++ b/packages/integrations/vercel/test/fixtures/static/package.json @@ -0,0 +1,9 @@ +{ + "name": "@test/astro-vercel-static", + "version": "0.0.0", + "private": true, + "dependencies": { + "@astrojs/vercel": "workspace:*", + "astro": "workspace:*" + } +} diff --git a/packages/integrations/vercel/test/fixtures/static/src/pages/404.astro b/packages/integrations/vercel/test/fixtures/static/src/pages/404.astro new file mode 100644 index 000000000000..9e307c5c292c --- /dev/null +++ b/packages/integrations/vercel/test/fixtures/static/src/pages/404.astro @@ -0,0 +1,8 @@ + + + 404 + + +

404

+ + diff --git a/packages/integrations/vercel/test/fixtures/static/src/pages/one.astro b/packages/integrations/vercel/test/fixtures/static/src/pages/one.astro new file mode 100644 index 000000000000..0c7fb90a735e --- /dev/null +++ b/packages/integrations/vercel/test/fixtures/static/src/pages/one.astro @@ -0,0 +1,8 @@ + + + One + + +

One

+ + diff --git a/packages/integrations/vercel/test/fixtures/static/src/pages/two.astro b/packages/integrations/vercel/test/fixtures/static/src/pages/two.astro new file mode 100644 index 000000000000..e7ba9910e2a6 --- /dev/null +++ b/packages/integrations/vercel/test/fixtures/static/src/pages/two.astro @@ -0,0 +1,8 @@ + + + Two + + +

Two

+ + diff --git a/packages/integrations/vercel/test/static.test.js b/packages/integrations/vercel/test/static.test.js new file mode 100644 index 000000000000..db8e48a5ab50 --- /dev/null +++ b/packages/integrations/vercel/test/static.test.js @@ -0,0 +1,26 @@ +import { loadFixture } from './test-utils.js'; +import { expect } from 'chai'; + +describe('maxDuration', () => { + /** @type {import('./test-utils.js').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/static/', + }); + await fixture.build(); + }); + + it('falls back to 404.html', async () => { + const deploymentConfig = JSON.parse( + await fixture.readFile('../.vercel/output/config.json') + ); + // change the index if necesseary + expect(deploymentConfig.routes[2]).to.deep.include({ + src: '/.*', + dest: '/404.html', + status: 404 + }); + }); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7902ad244ac2..886813027c20 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4767,6 +4767,15 @@ importers: specifier: workspace:* version: link:../../../../../astro + packages/integrations/vercel/test/fixtures/static: + dependencies: + '@astrojs/vercel': + specifier: workspace:* + version: link:../../.. + astro: + specifier: workspace:* + version: link:../../../../../astro + packages/integrations/vercel/test/fixtures/static-assets: dependencies: '@astrojs/vercel':