2023-02-03 15:19:44 +00:00
|
|
|
import { loadFixture } from './test-utils.js';
|
2023-01-30 19:50:44 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import cloudflare from '../dist/index.js';
|
|
|
|
|
2023-02-03 15:19:44 +00:00
|
|
|
/** @type {import('./test-utils').Fixture} */
|
2023-01-30 19:50:44 +00:00
|
|
|
describe('mode: "directory"', () => {
|
|
|
|
let fixture;
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
fixture = await loadFixture({
|
|
|
|
root: './fixtures/basics/',
|
2023-02-03 15:19:44 +00:00
|
|
|
output: 'server',
|
2023-01-30 19:52:54 +00:00
|
|
|
adapter: cloudflare({ mode: 'directory' }),
|
2023-06-05 13:03:20 +00:00
|
|
|
redirects: {
|
|
|
|
'/old': '/'
|
|
|
|
},
|
|
|
|
experimental: {
|
|
|
|
redirects: true,
|
|
|
|
},
|
2023-01-30 19:50:44 +00:00
|
|
|
});
|
2023-02-03 15:19:44 +00:00
|
|
|
await fixture.build();
|
2023-01-30 19:50:44 +00:00
|
|
|
});
|
|
|
|
|
2023-02-03 15:19:44 +00:00
|
|
|
it('generates functions folder inside the project root', async () => {
|
|
|
|
expect(await fixture.pathExists('../functions')).to.be.true;
|
2023-02-13 01:19:38 +00:00
|
|
|
expect(await fixture.pathExists('../functions/[[path]].js')).to.be.true;
|
2023-01-30 19:50:44 +00:00
|
|
|
});
|
2023-06-05 13:03:20 +00:00
|
|
|
|
|
|
|
it('generates a redirects file', async () => {
|
|
|
|
try {
|
|
|
|
let _redirects = await fixture.readFile('/_redirects');
|
|
|
|
let parts = _redirects.split(/\s+/);
|
|
|
|
expect(parts).to.deep.equal([
|
|
|
|
'/old', '/', '301'
|
|
|
|
]);
|
|
|
|
} catch {
|
|
|
|
expect(false).to.equal(true);
|
|
|
|
}
|
|
|
|
});
|
2023-01-30 19:50:44 +00:00
|
|
|
});
|