Added test for dir parameter in astro:build:done. (#3649)

* Added test for dir in astro:build:done

* Added changeset

* Change pathname for Windows

* Change changeset generated file summary

* Eliminate testing of branches by os

* Eliminate OS dependence

* Change changeset generated file summary

* Using fileURLToPath

* Cross-platform fixes.

* Use posix for everything.

* Pass an empty string for relative from

* Use path.join for the correct value

* Update packages/astro/test/static-build-dir.test.js

* Update packages/astro/test/static-build-dir.test.js

* Update packages/astro/test/static-build-dir.test.js

* Remove trailing slash

* add toString

* fix syntax error

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
d-suke 2022-06-24 04:04:10 +09:00 committed by GitHub
parent e990b9f42d
commit 446f8c4f13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Added test for dir parameter in astro:build:done

View file

@ -0,0 +1,8 @@
{
"name": "@test/static-build-dir",
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*"
}
}

View file

@ -0,0 +1,10 @@
---
import {Code} from 'astro/components';
---
<html>
<head><title>Testing</title></head>
<body>
<h1>Test</h1>
<Code lang="js" code={`const foo = 'bar';`} />
</body>
</html>

View file

@ -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())
);
});
});

View file

@ -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:*