diff --git a/sui/storages/local/build_test.go b/sui/storages/local/build_test.go
index edcf1c166..b623f856c 100644
--- a/sui/storages/local/build_test.go
+++ b/sui/storages/local/build_test.go
@@ -19,7 +19,17 @@ func TestTemplateBuild(t *testing.T) {
t.Fatalf("GetTemplate error: %v", err)
}
- err = tmpl.Build(&core.BuildOption{SSR: true})
+ root := application.App.Root()
+ public := tmpl.(*Template).local.GetPublic()
+ path := filepath.Join(root, "public", public.Root)
+
+ // Remove files and directories in Public directory if exists
+ err = os.RemoveAll(path)
+ if err != nil && !os.IsNotExist(err) {
+ t.Fatalf("RemoveAll error: %v", err)
+ }
+
+ err = tmpl.Build(&core.BuildOption{SSR: true, ExecScripts: true})
if err != nil {
t.Fatalf("Components error: %v", err)
}
@@ -27,11 +37,7 @@ func TestTemplateBuild(t *testing.T) {
index := "/index.sui"
// Check SUI
- root := application.App.Root()
- public := tmpl.(*Template).local.GetPublic()
- path := filepath.Join(root, "public", public.Root)
assert.FileExists(t, filepath.Join(path, index))
-
content, err := os.ReadFile(filepath.Join(path, index))
if err != nil {
t.Fatalf("ReadFile error: %v", err)
@@ -54,6 +60,16 @@ func TestTemplateBuildAsComponent(t *testing.T) {
t.Fatalf("GetTemplate error: %v", err)
}
+ root := application.App.Root()
+ public := tmpl.(*Template).local.GetPublic()
+ path := filepath.Join(root, "public", public.Root)
+
+ // Remove files and directories in Public directory if exists
+ err = os.RemoveAll(path)
+ if err != nil && !os.IsNotExist(err) {
+ t.Fatalf("RemoveAll error: %v", err)
+ }
+
err = tmpl.Build(&core.BuildOption{SSR: true})
if err != nil {
t.Fatalf("Components error: %v", err)
@@ -63,9 +79,100 @@ func TestTemplateBuildAsComponent(t *testing.T) {
cinput := "/flowbite/components/edit/input.jit"
// Check JIT
+ assert.FileExists(t, filepath.Join(path, cselect))
+ assert.FileExists(t, filepath.Join(path, cinput))
+
+ content, err := os.ReadFile(filepath.Join(path, cselect))
+ if err != nil {
+ t.Fatalf("ReadFile error: %v", err)
+ }
+
+ assert.NotContains(t, string(content), "body")
+ assert.NotContains(t, string(content), ``)
+ assert.Contains(t, string(content), `