MCPcopy
hub / github.com/livebud/bud / TestNodeModules

Function TestNodeModules

framework/view/dom/dom_test.go:94–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestNodeModules(t *testing.T) {
95 is := is.New(t)
96 log := testlog.New()
97 ctx := context.Background()
98 dir := t.TempDir()
99 td := testdir.New(dir)
100 td.Files["view/index.svelte"] = `<h1>hi world</h1>`
101 td.NodeModules["svelte"] = versions.Svelte
102 is.NoErr(td.Write(ctx))
103 module, err := gomod.Find(dir)
104 is.NoErr(err)
105 gfs := genfs.New(dag.Discard, module, log)
106 gfs.FileServer("bud/node_modules", nodemodules.New(module))
107 // Read the re-written node_modules
108 code, err := fs.ReadFile(gfs, "bud/node_modules/svelte/internal")
109 is.NoErr(err)
110 is.True(strings.Contains(string(code), `function element(`))
111 is.True(strings.Contains(string(code), `function text(`))
112}
113
114func TestGenerateDir(t *testing.T) {
115 is := is.New(t)

Callers

nothing calls this directly

Calls 10

NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
FindFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NoErrMethod · 0.80
TrueMethod · 0.80
FileServerMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected