summaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/test/functions
diff options
context:
space:
mode:
authorGravatar Erika <3019731+Princesseuh@users.noreply.github.com> 2023-08-16 10:21:05 +0200
committerGravatar GitHub <noreply@github.com> 2023-08-16 10:21:05 +0200
commitb76c166bdd8e28683f62806aef968d1e0c3b06d9 (patch)
tree31a737ce2999e8cd625f3948b4bf326ed8b6489a /packages/integrations/netlify/test/functions
parente12a1018429eb506a8507a4b9ae57388be4d0f7f (diff)
downloadastro-b76c166bdd8e28683f62806aef968d1e0c3b06d9.tar.gz
astro-b76c166bdd8e28683f62806aef968d1e0c3b06d9.tar.zst
astro-b76c166bdd8e28683f62806aef968d1e0c3b06d9.zip
feat: unflag experimental.assets (#7921)
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Diffstat (limited to 'packages/integrations/netlify/test/functions')
-rw-r--r--packages/integrations/netlify/test/functions/prerender.test.js17
-rw-r--r--packages/integrations/netlify/test/functions/redirects.test.js8
-rw-r--r--packages/integrations/netlify/test/functions/redirects.test.js.snap1
-rw-r--r--packages/integrations/netlify/test/functions/split-support.test.js22
4 files changed, 30 insertions, 18 deletions
diff --git a/packages/integrations/netlify/test/functions/prerender.test.js b/packages/integrations/netlify/test/functions/prerender.test.js
index a571dd76e..05a2c3971 100644
--- a/packages/integrations/netlify/test/functions/prerender.test.js
+++ b/packages/integrations/netlify/test/functions/prerender.test.js
@@ -1,7 +1,7 @@
import { expect } from 'chai';
+import { after } from 'node:test';
import netlifyAdapter from '../../dist/index.js';
import { loadFixture, testIntegration } from './test-utils.js';
-import { after } from 'node:test';
describe('Mixed Prerendering with SSR', () => {
/** @type {import('./test-utils').Fixture} */
@@ -27,9 +27,9 @@ describe('Mixed Prerendering with SSR', () => {
it('Wildcard 404 is sorted last', async () => {
const redir = await fixture.readFile('/_redirects');
- const baseRouteIndex = redir.indexOf('/ /.netlify/functions/entry 200');
- const oneRouteIndex = redir.indexOf('/one /one/index.html 200');
- const fourOhFourWildCardIndex = redir.indexOf('/* /.netlify/functions/entry 404');
+ const baseRouteIndex = redir.indexOf('/ /.netlify/functions/entry 200');
+ const oneRouteIndex = redir.indexOf('/one /one/index.html 200');
+ const fourOhFourWildCardIndex = redir.indexOf('/* /.netlify/functions/entry 404');
expect(oneRouteIndex).to.not.be.equal(-1);
expect(fourOhFourWildCardIndex).to.be.greaterThan(baseRouteIndex);
@@ -61,12 +61,15 @@ describe('Mixed Hybrid rendering with SSR', () => {
it('outputs a correct redirect file', async () => {
const redir = await fixture.readFile('/_redirects');
- const baseRouteIndex = redir.indexOf('/one /.netlify/functions/entry 200');
- const rootRouteIndex = redir.indexOf('/ /index.html 200');
- const fourOhFourIndex = redir.indexOf('/404 /404.html 200');
+ console.log(redir);
+ const baseRouteIndex = redir.indexOf('/one /.netlify/functions/entry 200');
+ const rootRouteIndex = redir.indexOf('/ /index.html 200');
+ const fourOhFourIndex = redir.indexOf('/404 /404.html 200');
+ const imageEndpoint = redir.indexOf('/_image /.netlify/functions/entry 200');
expect(rootRouteIndex).to.not.be.equal(-1);
expect(baseRouteIndex).to.not.be.equal(-1);
expect(fourOhFourIndex).to.not.be.equal(-1);
+ expect(imageEndpoint).to.not.be.equal(-1);
});
});
diff --git a/packages/integrations/netlify/test/functions/redirects.test.js b/packages/integrations/netlify/test/functions/redirects.test.js
index 1995718f8..8e3d46a68 100644
--- a/packages/integrations/netlify/test/functions/redirects.test.js
+++ b/packages/integrations/netlify/test/functions/redirects.test.js
@@ -1,6 +1,6 @@
import { expect } from 'chai';
-import { loadFixture, testIntegration } from './test-utils.js';
import netlifyAdapter from '../../dist/index.js';
+import { loadFixture, testIntegration } from './test-utils.js';
describe('SSG - Redirects', () => {
/** @type {import('../../../astro/test/test-utils').Fixture} */
@@ -25,6 +25,7 @@ describe('SSG - Redirects', () => {
it('Creates a redirects file', async () => {
let redirects = await fixture.readFile('/_redirects');
let parts = redirects.split(/\s+/);
+ console.log(parts);
expect(parts).to.deep.equal([
'/other',
'/',
@@ -38,6 +39,11 @@ describe('SSG - Redirects', () => {
'/.netlify/functions/entry',
'200',
+ // Image endpoint
+ '/_image',
+ '/.netlify/functions/entry',
+ '200',
+
// A real route
'/team/articles/*',
'/.netlify/functions/entry',
diff --git a/packages/integrations/netlify/test/functions/redirects.test.js.snap b/packages/integrations/netlify/test/functions/redirects.test.js.snap
index 322b4ee85..54095f052 100644
--- a/packages/integrations/netlify/test/functions/redirects.test.js.snap
+++ b/packages/integrations/netlify/test/functions/redirects.test.js.snap
@@ -4,5 +4,6 @@ exports[`SSG - Redirects Creates a redirects file 1`] = `
"/other / 301
/nope /.netlify/functions/entry 200
/ /.netlify/functions/entry 200
+/_image /.netlify/functions/entry 200
/team/articles/* /.netlify/functions/entry 200"
`;
diff --git a/packages/integrations/netlify/test/functions/split-support.test.js b/packages/integrations/netlify/test/functions/split-support.test.js
index fde8b5eb1..90427523c 100644
--- a/packages/integrations/netlify/test/functions/split-support.test.js
+++ b/packages/integrations/netlify/test/functions/split-support.test.js
@@ -30,7 +30,7 @@ describe('Split support', () => {
it('outputs a correct redirect file', async () => {
const redir = await fixture.readFile('/_redirects');
const lines = redir.split(/[\r\n]+/);
- expect(lines.length).to.equal(2);
+ expect(lines.length).to.equal(3);
expect(lines[0].includes('/blog')).to.be.true;
expect(lines[0].includes('blog.astro')).to.be.true;
@@ -43,15 +43,17 @@ describe('Split support', () => {
describe('Should create multiple functions', () => {
it('and hit 200', async () => {
if (_entryPoints) {
- for (const [, filePath] of _entryPoints) {
- const { handler } = await import(filePath.toString());
- const resp = await handler({
- httpMethod: 'POST',
- headers: {},
- rawUrl: 'http://example.com/',
- body: '{}',
- });
- expect(resp.statusCode).to.equal(200);
+ for (const [routeData, filePath] of _entryPoints) {
+ if (routeData.route !== '/_image') {
+ const { handler } = await import(filePath.toString());
+ const resp = await handler({
+ httpMethod: 'GET',
+ headers: {},
+ rawUrl: `http://example.com${routeData.route}`,
+ body: '{}',
+ });
+ expect(resp.statusCode).to.equal(200);
+ }
}
} else {
expect(false).to.be.true;