diff --git a/.changeset/modern-dots-smile.md b/.changeset/modern-dots-smile.md new file mode 100644 index 000000000..a66e9c34d --- /dev/null +++ b/.changeset/modern-dots-smile.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Added test for dir parameter in astro:build:done diff --git a/packages/astro/test/fixtures/static-build-dir/package.json b/packages/astro/test/fixtures/static-build-dir/package.json new file mode 100644 index 000000000..89902a729 --- /dev/null +++ b/packages/astro/test/fixtures/static-build-dir/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/static-build-dir", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/static-build-dir/src/pages/index.astro b/packages/astro/test/fixtures/static-build-dir/src/pages/index.astro new file mode 100644 index 000000000..e2f564a3b --- /dev/null +++ b/packages/astro/test/fixtures/static-build-dir/src/pages/index.astro @@ -0,0 +1,10 @@ +--- +import {Code} from 'astro/components'; +--- + +
+
+
diff --git a/packages/astro/test/static-build-dir.test.js b/packages/astro/test/static-build-dir.test.js
new file mode 100644
index 000000000..d09756af2
--- /dev/null
+++ b/packages/astro/test/static-build-dir.test.js
@@ -0,0 +1,29 @@
+import { expect } from 'chai';
+import { loadFixture } from './test-utils.js';
+
+describe('Static build: dir takes the URL path to the output directory', () => {
+ /** @type {URL} */
+ let checkDir;
+ before(async () => {
+ const fixture = await loadFixture({
+ root: './fixtures/static-build-dir/',
+ integrations: [
+ {
+ name: '@astrojs/dir',
+ hooks: {
+ 'astro:build:done': ({ dir }) => {
+ checkDir = dir;
+ },
+ },
+ },
+ ],
+ });
+ await fixture.build();
+ });
+ it('dir takes the URL path to the output directory', async () => {
+ const removeTrailingSlash = (str) => str.replace(/\/$/, '');
+ expect(removeTrailingSlash(checkDir.toString())).to.be.equal(
+ removeTrailingSlash(new URL('./fixtures/static-build-dir/dist', import.meta.url).toString())
+ );
+ });
+});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 65317d88a..70337edc6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1662,6 +1662,12 @@ importers:
dependencies:
astro: link:../../..
+ packages/astro/test/fixtures/static-build-dir:
+ specifiers:
+ astro: workspace:*
+ dependencies:
+ astro: link:../../..
+
packages/astro/test/fixtures/static-build-frameworks:
specifiers:
'@astrojs/preact': workspace:*