WIP! A BB-style forum, on the ATmosphere!
We're still working... we'll be back soon when we have something to show off!
node
typescript
hono
htmx
atproto
1import { describe, it, expect } from "vitest";
2import { Hono } from "hono";
3import { Button } from "../button.js";
4
5describe("Button", () => {
6 it("renders as <button> when no href provided", async () => {
7 const app = new Hono().get("/", (c) =>
8 c.html(<Button variant="primary">Click</Button>)
9 );
10 const res = await app.request("/");
11 const html = await res.text();
12 expect(html).toContain("<button");
13 expect(html).toContain("btn-primary");
14 expect(html).toContain("Click");
15 });
16
17 it("renders as <a> when href provided", async () => {
18 const app = new Hono().get("/", (c) =>
19 c.html(<Button variant="secondary" href="/boards">Go</Button>)
20 );
21 const res = await app.request("/");
22 const html = await res.text();
23 expect(html).toContain("<a ");
24 expect(html).toContain('href="/boards"');
25 expect(html).toContain("btn-secondary");
26 });
27
28 it("renders danger variant", async () => {
29 const app = new Hono().get("/", (c) =>
30 c.html(<Button variant="danger">Delete</Button>)
31 );
32 const res = await app.request("/");
33 const html = await res.text();
34 expect(html).toContain("btn-danger");
35 });
36
37 it("includes base btn class on all variants", async () => {
38 const app = new Hono().get("/", (c) =>
39 c.html(<Button variant="primary">x</Button>)
40 );
41 const res = await app.request("/");
42 const html = await res.text();
43 expect(html).toMatch(/class="btn /);
44 });
45});