astro/packages/astro/test/static-build-dir.test.js
Tony Sullivan b0cc939961
Adds a new "astro:build:generated" hook for SSG builds (#4775)
* Revert "Revert "Adds a new "astro:build:generated" hook for SSG builds (#4772)" (#4774)"

This reverts commit 13a4b0d488.

* fix: updating for latest merge with main
2022-09-21 17:13:36 +00:00

35 lines
1,001 B
JavaScript

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;
/** @type {URL} */
let checkGeneratedDir;
before(async () => {
const fixture = await loadFixture({
root: './fixtures/static-build-dir/',
integrations: [
{
name: '@astrojs/dir',
hooks: {
'astro:build:generated': ({ dir }) => {
checkGeneratedDir = dir;
},
'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())
);
expect(checkDir.toString()).to.be.equal(checkGeneratedDir.toString());
});
});