|
14 | 14 | import assert from 'assert';
|
15 | 15 | import esmock from 'esmock';
|
16 | 16 | import { FileS3Loader } from './FileS3Loader.js';
|
17 |
| -import { PipelineRequest, PipelineState } from '../src/index.js'; |
| 17 | +import { htmlPipe, PipelineRequest, PipelineState } from '../src/index.js'; |
18 | 18 |
|
19 | 19 | describe('Index Tests', () => {
|
| 20 | + it('responds with 404 for invalid path', async () => { |
| 21 | + const resp = await htmlPipe( |
| 22 | + new PipelineState({ path: '/foo.hidden.html' }), |
| 23 | + new PipelineRequest(new URL('https://www.hlx.live/')), |
| 24 | + ); |
| 25 | + assert.strictEqual(resp.status, 404); |
| 26 | + assert.strictEqual(resp.headers.get('x-error'), 'invalid path'); |
| 27 | + }); |
| 28 | + |
20 | 29 | it('responds with 500 for pipeline errors', async () => {
|
21 | 30 | /** @type htmlPipe */
|
22 |
| - const { htmlPipe } = await esmock('../src/html-pipe.js', { |
| 31 | + const { htmlPipe: mockPipe } = await esmock('../src/html-pipe.js', { |
23 | 32 | '../src/steps/fetch-config.js': () => {
|
24 | 33 | throw Error('kaputt');
|
25 | 34 | },
|
26 | 35 | });
|
27 | 36 |
|
28 |
| - const resp = await htmlPipe( |
| 37 | + const resp = await mockPipe( |
29 | 38 | new PipelineState({ s3Loader: new FileS3Loader() }),
|
30 | 39 | new PipelineRequest(new URL('https://www.hlx.live/')),
|
31 | 40 | );
|
|
0 commit comments