-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathparser_test.go
56 lines (48 loc) · 1.26 KB
/
parser_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package vueglue
import (
"os"
"strings"
"testing"
)
func TestDevServer(t *testing.T) {
config := &ViteConfig{
Environment: "development",
AssetsPath: "tests/testdata",
URLPrefix: "/",
FS: os.DirFS("testdata"),
EntryPoint: "main.ts",
ViteVersion: "3",
}
// check default tag generated
glue, err := initializeVueGlue(config)
if err != nil {
t.Fatalf("lib did not initialize: %s", err)
}
shouldContain := "main.ts"
if glue.MainModule != shouldContain {
t.Fatalf("dev tag looks wrong. expected %s, got %s", shouldContain, glue.MainModule)
}
tags, err := glue.RenderTags()
if err != nil {
t.Fatalf("tags did not render: %s", err)
}
// t.Logf("tags: %s", string(tags))
shouldContain = "http://localhost:5173/main.ts"
if !strings.Contains(string(tags), shouldContain) {
t.Fatalf("tags did not contain '%s'", shouldContain)
}
// change defaults
config.DevServerPort = "3001"
glue, err = initializeVueGlue(config)
if err != nil {
t.Fatalf("could not parse config: %s", err)
}
tags, err = glue.RenderTags()
if err != nil {
t.Fatalf("non-default tags not rendered: %s", err)
}
shouldContain = glue.BaseURL + "/main.ts"
if !strings.Contains(string(tags), shouldContain) {
t.Fatalf("tags did not contain '%s'", shouldContain)
}
}