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

Function TestConsoleLog

framework/view/view_test.go:264–298  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

262}
263
264func TestConsoleLog(t *testing.T) {
265 is := is.New(t)
266 ctx := context.Background()
267 dir := t.TempDir()
268 td := testdir.New(dir)
269 td.Files["controller/controller.go"] = `
270 package controller
271 type Controller struct {}
272 func (c *Controller) Index() string { return "" }
273 `
274 td.Files["view/index.svelte"] = `
275 <script>
276 console.log("log", "!", "!")
277 </script>
278 <h1>hello</h1>
279 `
280 td.NodeModules["svelte"] = versions.Svelte
281 td.NodeModules["livebud"] = "*"
282 is.NoErr(td.Write(ctx))
283 cli := testcli.New(dir)
284 app, err := cli.Start(ctx, "run")
285 is.NoErr(err)
286 defer app.Close()
287 res, err := app.Get("/")
288 is.NoErr(err)
289 is.NoErr(res.DiffHeaders(`
290 HTTP/1.1 200 OK
291 Transfer-Encoding: chunked
292 Content-Type: text/html
293 `))
294 is.In(res.Body().String(), "<h1>hello</h1>")
295 is.NoErr(app.Close())
296 is.In(app.Stdout(), "") // TODO: console.log() should go to stdout
297 is.In(app.Stderr(), "")
298}
299
300func TestConsoleError(t *testing.T) {
301 // TODO: console.error needs to be added to:

Callers

nothing calls this directly

Calls 14

NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NoErrMethod · 0.80
DiffHeadersMethod · 0.80
InMethod · 0.80
BodyMethod · 0.80
CloseMethod · 0.65
GetMethod · 0.65
StringMethod · 0.65
WriteMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected