mirror of
https://github.com/gin-gonic/gin.git
synced 2025-12-13 13:12:17 +08:00
Add test for nested JavaScript file
This commit is contained in:
parent
670895b7b2
commit
8ef5a66294
@ -669,6 +669,22 @@ func TestRouteStaticFSCleansPath(t *testing.T) {
|
|||||||
assert.Contains(t, w.Body.String(), "This is another simple embedded page.")
|
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) {
|
func TestRouterStaticFSFileNotFound(t *testing.T) {
|
||||||
router := New()
|
router := New()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user