Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe committed Sep 30, 2024
1 parent 0cb4abc commit be761b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/assets/static-absolute-root-with-dots/hello.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello with absolute root with dots
13 changes: 13 additions & 0 deletions test/serve-static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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')
})
})

0 comments on commit be761b2

Please sign in to comment.