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