diff --git a/src/adapter/cloudflare-workers/serve-static.test.ts b/src/adapter/cloudflare-workers/serve-static.test.ts index 17d6630b92..2d1306850a 100644 --- a/src/adapter/cloudflare-workers/serve-static.test.ts +++ b/src/adapter/cloudflare-workers/serve-static.test.ts @@ -31,7 +31,8 @@ Object.assign(global, { describe('ServeStatic Middleware', () => { const app = new Hono() - app.use('/static/*', serveStatic({ root: './assets' })) + const onNotFound = vi.fn(() => {}) + app.use('/static/*', serveStatic({ root: './assets', onNotFound })) app.use('/static-no-root/*', serveStatic()) app.use( '/dot-static/*', @@ -41,11 +42,14 @@ describe('ServeStatic Middleware', () => { }) ) + beforeEach(() => onNotFound.mockClear()) + it('Should return plain.txt', async () => { const res = await app.request('http://localhost/static/plain.txt') expect(res.status).toBe(200) expect(await res.text()).toBe('This is plain.txt') expect(res.headers.get('Content-Type')).toBe('text/plain; charset=utf-8') + expect(onNotFound).not.toHaveBeenCalled() }) it('Should return hono.html', async () => { @@ -53,11 +57,13 @@ describe('ServeStatic Middleware', () => { expect(res.status).toBe(200) expect(await res.text()).toBe('