diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2024-01-27 17:19:31 +0000 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2024-01-27 17:19:31 +0000 |
commit | afb57d6dbdeb1628d420411a41fdbbd479b6732f (patch) | |
tree | 7d057f44d5c9d5ffe6376542e102446cc4760fa8 /test/apps | |
parent | 5510116297d5da07269b776a0e30766e221569bd (diff) | |
download | lustre-afb57d6dbdeb1628d420411a41fdbbd479b6732f.tar.gz lustre-afb57d6dbdeb1628d420411a41fdbbd479b6732f.zip |
:alembic: Set up some basic snapshot tests.
Diffstat (limited to 'test/apps')
-rw-r--r-- | test/apps/counter.gleam | 41 | ||||
-rw-r--r-- | test/apps/static.gleam | 17 |
2 files changed, 58 insertions, 0 deletions
diff --git a/test/apps/counter.gleam b/test/apps/counter.gleam new file mode 100644 index 0000000..b58b2ee --- /dev/null +++ b/test/apps/counter.gleam @@ -0,0 +1,41 @@ +// IMPORTS --------------------------------------------------------------------- + +import gleam/int +import lustre/element.{text} +import lustre/element/html.{button, div, p} +import lustre/event + +// MODEL ----------------------------------------------------------------------- + +pub type Model = + Int + +pub fn init(count) { + count +} + +// UPDATE ---------------------------------------------------------------------- + +pub type Msg { + Increment + Decrement +} + +pub fn update(model, msg) { + case msg { + Increment -> model + 1 + Decrement -> model - 1 + } +} + +// VIEW ------------------------------------------------------------------------ + +pub fn view(model) { + let count = int.to_string(model) + + div([], [ + p([], [text(count)]), + button([event.on_click(Decrement)], [text("-")]), + button([event.on_click(Increment)], [text("+")]), + ]) +} diff --git a/test/apps/static.gleam b/test/apps/static.gleam new file mode 100644 index 0000000..d41964a --- /dev/null +++ b/test/apps/static.gleam @@ -0,0 +1,17 @@ +// IMPORTS --------------------------------------------------------------------- + +import lustre/attribute.{src} +import lustre/element.{text} +import lustre/element/html.{body, h1, head, html, img, title} + +// VIEW ------------------------------------------------------------------------ + +pub fn view() { + html([], [ + head([], [title([], "Hello, World!")]), + body([], [ + h1([], [text("Hello, World!")]), + img([src("https://source.unsplash.com/random")]), + ]), + ]) +} |