Skip to content

Commit

Permalink
test(netlify): add base fixture and prepare test (#45) (#49)
Browse files Browse the repository at this point in the history
* test(netlify): add base fixture and prepare test

* Update base.test.js

* fix(netlify): test indentation

---------

Co-authored-by: Alexander Niebuhr <alexander@nbhr.io>
  • Loading branch information
florian-lefebvre and alexanderniebuhr authored Nov 3, 2023
1 parent 6ac9017 commit 3540bd2
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/netlify/test/functions/base.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect } from 'chai';
import fs from 'fs/promises';
import { cli } from './test-utils.js';
import { fileURLToPath } from 'url';

const root = new URL('./fixtures/base/', import.meta.url).toString();

describe('Base', () => {
before(async () => {
await cli('build', '--root', fileURLToPath(root));
});

it('Path is prepended by base', async () => {
const redir = await fs.readFile(new URL('./dist/_redirects', root), 'utf-8');
const baseRouteIndex = redir.indexOf('/test/ /.netlify/functions/entry 200');
const imageEndpoint = redir.indexOf('/test/_image /.netlify/functions/entry 200');

expect(baseRouteIndex).to.not.be.equal(-1);
expect(imageEndpoint).to.not.be.equal(-1);
});
});
10 changes: 10 additions & 0 deletions packages/netlify/test/functions/fixtures/base/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify';

export default defineConfig({
base: "/test",
trailingSlash: "always",
output: 'server',
adapter: netlify(),
site: `http://example.com`,
});
6 changes: 6 additions & 0 deletions packages/netlify/test/functions/fixtures/base/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@test/netlify-base",
"dependencies": {
"@astrojs/netlify": "workspace:"
}
}
1 change: 1 addition & 0 deletions packages/netlify/test/functions/fixtures/base/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="astro/client" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
---
<html>
<head>
<title>Testing</title>
</head>
<body>
<h1>Testing</h1>
</body>
</html>
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3540bd2

Please sign in to comment.