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:
parent
e990b9f42d
commit
446f8c4f13
5 changed files with 58 additions and 0 deletions
5
.changeset/modern-dots-smile.md
Normal file
5
.changeset/modern-dots-smile.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Added test for dir parameter in astro:build:done
|
8
packages/astro/test/fixtures/static-build-dir/package.json
vendored
Normal file
8
packages/astro/test/fixtures/static-build-dir/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "@test/static-build-dir",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"astro": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
10
packages/astro/test/fixtures/static-build-dir/src/pages/index.astro
vendored
Normal file
10
packages/astro/test/fixtures/static-build-dir/src/pages/index.astro
vendored
Normal 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>
|
29
packages/astro/test/static-build-dir.test.js
Normal file
29
packages/astro/test/static-build-dir.test.js
Normal 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())
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
|
@ -1662,6 +1662,12 @@ importers:
|
||||||
dependencies:
|
dependencies:
|
||||||
astro: link:../../..
|
astro: link:../../..
|
||||||
|
|
||||||
|
packages/astro/test/fixtures/static-build-dir:
|
||||||
|
specifiers:
|
||||||
|
astro: workspace:*
|
||||||
|
dependencies:
|
||||||
|
astro: link:../../..
|
||||||
|
|
||||||
packages/astro/test/fixtures/static-build-frameworks:
|
packages/astro/test/fixtures/static-build-frameworks:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@astrojs/preact': workspace:*
|
'@astrojs/preact': workspace:*
|
||||||
|
|
Loading…
Reference in a new issue