Add test for nested JavaScript file

This commit is contained in:
Nico Clack 2025-11-23 14:01:27 +00:00
parent 670895b7b2
commit 8ef5a66294

View File

@ -669,6 +669,22 @@ func TestRouteStaticFSCleansPath(t *testing.T) {
assert.Contains(t, w.Body.String(), "This is another simple embedded page.")
}
func TestRouteStaticFSNestedJsFile(t *testing.T) {
router := New()
subFS, err := fs.Sub(embeddedFolder, embeddedPath)
require.NoError(t, err)
fs := &OnlyFilesFS{
FileSystem: http.FS(subFS),
}
router.StaticFS("/", fs)
router.NoRoute(func(c *Context) {
c.String(http.StatusNotFound, "non existent")
})
w := PerformRequest(router, http.MethodGet, "/tutorials/making-gin/main.js")
assert.Contains(t, w.Body.String(), "console.log(\"This is a simple embedded JavaScript file.\");")
}
func TestRouterStaticFSFileNotFound(t *testing.T) {
router := New()