| 262 | } |
| 263 | |
| 264 | func 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 | |
| 300 | func TestConsoleError(t *testing.T) { |
| 301 | // TODO: console.error needs to be added to: |