summaryrefslogtreecommitdiff
path: root/packages/integrations/netlify/test/functions
diff options
context:
space:
mode:
authorGravatar alexanderniebuhr <alexanderniebuhr@users.noreply.github.com> 2024-02-16 09:57:45 +0000
committerGravatar astrobot-houston <fred+astrobot@astro.build> 2024-02-16 09:57:45 +0000
commit768ef569a34f4e6e2e12df8946ee861823d0685e (patch)
tree5795bf25e74816c85764441e8d14d2cd5e70d36d /packages/integrations/netlify/test/functions
parent5bbbeaff265de7e663124fa19170764b3d0372ba (diff)
downloadastro-768ef569a34f4e6e2e12df8946ee861823d0685e.tar.gz
astro-768ef569a34f4e6e2e12df8946ee861823d0685e.tar.zst
astro-768ef569a34f4e6e2e12df8946ee861823d0685e.zip
[ci] format
Diffstat (limited to 'packages/integrations/netlify/test/functions')
-rw-r--r--packages/integrations/netlify/test/functions/cookies.test.js16
-rw-r--r--packages/integrations/netlify/test/functions/edge-middleware.test.js17
-rw-r--r--packages/integrations/netlify/test/functions/image-cdn.test.js13
-rw-r--r--packages/integrations/netlify/test/functions/redirects.test.js20
4 files changed, 34 insertions, 32 deletions
diff --git a/packages/integrations/netlify/test/functions/cookies.test.js b/packages/integrations/netlify/test/functions/cookies.test.js
index 9d25a873e..c4384f8e0 100644
--- a/packages/integrations/netlify/test/functions/cookies.test.js
+++ b/packages/integrations/netlify/test/functions/cookies.test.js
@@ -1,6 +1,6 @@
-import { loadFixture } from '@astrojs/test-utils';
-import { describe, it, before } from 'node:test';
import * as assert from 'node:assert/strict';
+import { before, describe, it } from 'node:test';
+import { loadFixture } from '@astrojs/test-utils';
describe('Cookies', () => {
let fixture;
@@ -20,9 +20,9 @@ describe('Cookies', () => {
new Request('http://example.com/login', { method: 'POST', body: '{}' }),
{}
);
- assert.equal(resp.status,301);
- assert.equal(resp.headers.get('location'),'/');
- assert.deepEqual(resp.headers.getSetCookie(),['foo=foo; HttpOnly', 'bar=bar; HttpOnly']);
+ assert.equal(resp.status, 301);
+ assert.equal(resp.headers.get('location'), '/');
+ assert.deepEqual(resp.headers.getSetCookie(), ['foo=foo; HttpOnly', 'bar=bar; HttpOnly']);
});
it('renders dynamic 404 page', async () => {
@@ -39,9 +39,9 @@ describe('Cookies', () => {
}),
{}
);
- assert.equal(resp.status,404);
+ assert.equal(resp.status, 404);
const text = await resp.text();
- assert.equal(text.includes('This is my custom 404 page'),true);
- assert.equal(text.includes('x-test: bar'),true);
+ assert.equal(text.includes('This is my custom 404 page'), true);
+ assert.equal(text.includes('x-test: bar'), true);
});
});
diff --git a/packages/integrations/netlify/test/functions/edge-middleware.test.js b/packages/integrations/netlify/test/functions/edge-middleware.test.js
index 42de398c6..ec4fe66dd 100644
--- a/packages/integrations/netlify/test/functions/edge-middleware.test.js
+++ b/packages/integrations/netlify/test/functions/edge-middleware.test.js
@@ -1,6 +1,6 @@
-import { loadFixture } from '@astrojs/test-utils';
-import { describe, it, before, after } from 'node:test';
import * as assert from 'node:assert/strict';
+import { after, before, describe, it } from 'node:test';
+import { loadFixture } from '@astrojs/test-utils';
describe('Middleware', () => {
const root = new URL('./fixtures/middleware/', import.meta.url);
@@ -14,19 +14,22 @@ describe('Middleware', () => {
});
it('emits no edge function', async () => {
- assert.equal(fixture.pathExists('../.netlify/edge-functions/middleware/middleware.mjs'), false)
+ assert.equal(
+ fixture.pathExists('../.netlify/edge-functions/middleware/middleware.mjs'),
+ false
+ );
});
it('applies middleware to static files at build-time', async () => {
// prerendered page has middleware applied at build time
const prerenderedPage = await fixture.readFile('prerender/index.html');
- assert.equal(prerenderedPage.includes('<title>Middleware</title>'),true);
+ assert.equal(prerenderedPage.includes('<title>Middleware</title>'), true);
});
after(async () => {
process.env.EDGE_MIDDLEWARE = undefined;
await fixture.clean();
- })
+ });
});
describe('edgeMiddleware: true', () => {
@@ -46,12 +49,12 @@ describe('Middleware', () => {
it.skip('does not apply middleware during prerendering', async () => {
const prerenderedPage = await fixture.readFile('prerender/index.html');
- assert.equal(prerenderedPage.includes('<title></title>'),true);
+ assert.equal(prerenderedPage.includes('<title></title>'), true);
});
after(async () => {
process.env.EDGE_MIDDLEWARE = undefined;
await fixture.clean();
- })
+ });
});
});
diff --git a/packages/integrations/netlify/test/functions/image-cdn.test.js b/packages/integrations/netlify/test/functions/image-cdn.test.js
index 7a0060bff..31032363f 100644
--- a/packages/integrations/netlify/test/functions/image-cdn.test.js
+++ b/packages/integrations/netlify/test/functions/image-cdn.test.js
@@ -1,6 +1,6 @@
-import { loadFixture } from '@astrojs/test-utils';
-import { describe, it, after } from 'node:test';
import * as assert from 'node:assert/strict';
+import { after, describe, it } from 'node:test';
+import { loadFixture } from '@astrojs/test-utils';
describe('Image CDN', () => {
const root = new URL('./fixtures/middleware/', import.meta.url);
@@ -11,9 +11,8 @@ describe('Image CDN', () => {
await fixture.build();
const astronautPage = await fixture.readFile('astronaut/index.html');
- assert.equal(astronautPage.includes(`src="/_astro/astronaut.`),true);
+ assert.equal(astronautPage.includes(`src="/_astro/astronaut.`), true);
});
-
});
describe('when running inside of netlify', () => {
@@ -22,13 +21,13 @@ describe('Image CDN', () => {
process.env.DISABLE_IMAGE_CDN = undefined;
});
- it('enables Netlify Image CDN',async () => {
+ it('enables Netlify Image CDN', async () => {
process.env.NETLIFY = 'true';
const fixture = await loadFixture({ root });
await fixture.build();
const astronautPage = await fixture.readFile('astronaut/index.html');
- assert.equal(astronautPage.includes(`src="/.netlify/image`),true);
+ assert.equal(astronautPage.includes(`src="/.netlify/image`), true);
});
it('respects image CDN opt-out', async () => {
@@ -38,7 +37,7 @@ describe('Image CDN', () => {
await fixture.build();
const astronautPage = await fixture.readFile('astronaut/index.html');
- assert.equal(astronautPage.includes(`src="/_astro/astronaut.`),true);
+ assert.equal(astronautPage.includes(`src="/_astro/astronaut.`), true);
});
});
});
diff --git a/packages/integrations/netlify/test/functions/redirects.test.js b/packages/integrations/netlify/test/functions/redirects.test.js
index ab4d426ba..24b831ee0 100644
--- a/packages/integrations/netlify/test/functions/redirects.test.js
+++ b/packages/integrations/netlify/test/functions/redirects.test.js
@@ -1,7 +1,7 @@
import { createServer } from 'http';
-import { loadFixture } from '@astrojs/test-utils';
-import { describe, it, before } from 'node:test';
import * as assert from 'node:assert/strict';
+import { before, describe, it } from 'node:test';
+import { loadFixture } from '@astrojs/test-utils';
describe('SSR - Redirects', () => {
let fixture;
@@ -14,9 +14,9 @@ describe('SSR - Redirects', () => {
it('Creates a redirects file', async () => {
const redirects = await fixture.readFile('./_redirects');
const parts = redirects.split(/\s+/);
- assert.deepEqual(parts,['', '/other', '/', '301', '']);
+ assert.deepEqual(parts, ['', '/other', '/', '301', '']);
// Snapshots are not supported in Node.js test yet (https://github.com/nodejs/node/issues/48260)
- assert.equal(redirects,'\n/other / 301\n');
+ assert.equal(redirects, '\n/other / 301\n');
});
it('Does not create .html files', async () => {
@@ -26,7 +26,7 @@ describe('SSR - Redirects', () => {
} catch {
hasErrored = true;
}
- assert.equal(hasErrored,true, 'this file should not exist');
+ assert.equal(hasErrored, true, 'this file should not exist');
});
it('renders static 404 page', async () => {
@@ -36,10 +36,10 @@ describe('SSR - Redirects', () => {
);
const { default: handler } = await import(entryURL);
const resp = await handler(new Request('http://example.com/nonexistant-page'), {});
- assert.equal(resp.status,404);
- assert.equal(resp.headers.get('content-type'),'text/html; charset=utf-8');
+ assert.equal(resp.status, 404);
+ assert.equal(resp.headers.get('content-type'), 'text/html; charset=utf-8');
const text = await resp.text();
- assert.equal(text.includes('This is my static 404 page'),true);
+ assert.equal(text.includes('This is my static 404 page'), true);
});
it('does not pass through 404 request', async () => {
@@ -56,8 +56,8 @@ describe('SSR - Redirects', () => {
);
const { default: handler } = await import(entryURL);
const resp = await handler(new Request('http://localhost:5678/nonexistant-page'), {});
- assert.equal(resp.status,404);
- assert.equal(testServerCalls,0);
+ assert.equal(resp.status, 404);
+ assert.equal(testServerCalls, 0);
testServer.close();
});
});