blob: 228e5e9f12f4f1e80aa4e6a835428eb456c77f51 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import { expect } from 'chai';
import { existsSync, readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { astroCli } from './_test-utils.js';
const root = new URL('./fixtures/directory-mode/', import.meta.url);
describe('Directory mode', () => {
before(async () => {
await astroCli(fileURLToPath(root), 'build');
});
it('generates functions folder inside the project root', () => {
const testURL = new URL('functions', root);
expect(existsSync(fileURLToPath(testURL))).to.be.true;
});
it('generates functions file inside the project root', () => {
const testURL = new URL('functions/[[path]].js', root);
expect(existsSync(fileURLToPath(testURL))).to.be.true;
});
it('generates a redirects file', () => {
const testURL = new URL('dist/_redirects', root);
try {
let _redirects = readFileSync(fileURLToPath(testURL), 'utf-8');
let parts = _redirects.split(/\s+/);
expect(parts).to.deep.equal(['/old', '/', '301']);
} catch (e) {
expect(false).to.equal(true);
}
});
});
|