From be761b263477ade8cfedf2ca10fd59812bfa7ce5 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Mon, 30 Sep 2024 17:24:31 +0900 Subject: [PATCH] add more tests --- .../assets/static-absolute-root-with-dots/hello.txt | 1 + test/serve-static.test.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 test/assets/static-absolute-root-with-dots/hello.txt diff --git a/test/assets/static-absolute-root-with-dots/hello.txt b/test/assets/static-absolute-root-with-dots/hello.txt new file mode 100644 index 0000000..35fd066 --- /dev/null +++ b/test/assets/static-absolute-root-with-dots/hello.txt @@ -0,0 +1 @@ +Hello with absolute root with dots \ No newline at end of file diff --git a/test/serve-static.test.ts b/test/serve-static.test.ts index 35f89af..06dfab7 100644 --- a/test/serve-static.test.ts +++ b/test/serve-static.test.ts @@ -49,6 +49,11 @@ describe('Serve Static Middleware', () => { serveStatic({ root: path.join(path.dirname(__filename), 'assets') }) ) + app.all( + '/static-absolute-root-with-dots/*', + serveStatic({ root: path.join(path.dirname(__filename), 'assets') + '/../assets' }) + ) + const server = createAdaptorServer(app) it('Should return index.html', async () => { @@ -210,4 +215,12 @@ describe('Serve Static Middleware', () => { expect(res.headers['content-length']).toBe('24') expect(res.text).toBe('Hello with absolute root') }) + + it('Should return 200 with an absolute root with dots - /static-absolute-root-with-dots/hello.txt', async () => { + const res = await request(server).get('/static-absolute-root-with-dots/hello.txt') + expect(res.status).toBe(200) + expect(res.headers['content-type']).toBe('text/plain; charset=utf-8') + expect(res.headers['content-length']).toBe('34') + expect(res.text).toBe('Hello with absolute root with dots') + }) })