feat: add mobile-first daisyui server-rendered UI components
This commit is contained in:
33
test/views.test.js
Normal file
33
test/views.test.js
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
const { layout, renderHomePage, renderAudioPage } = require("../src/views/pages");
|
||||
|
||||
test("layout includes daisyui stylesheet and mobile-first wrapper", () => {
|
||||
const html = layout({ title: "t", content: "x" });
|
||||
assert.match(html, /daisyui@5/);
|
||||
assert.match(html, /max-w-md mx-auto p-4/);
|
||||
});
|
||||
|
||||
test("home page renders jobs list and wallet credits", () => {
|
||||
const html = renderHomePage({
|
||||
authenticated: true,
|
||||
userId: "u1",
|
||||
balance: 7,
|
||||
jobs: [{ assetId: "a1", status: "completed", article: { title: "Hello" } }],
|
||||
});
|
||||
|
||||
assert.match(html, /Wallet Credits/);
|
||||
assert.match(html, /7/);
|
||||
assert.match(html, /Hello/);
|
||||
});
|
||||
|
||||
test("audio page asks auth/payment when access is denied", () => {
|
||||
const html = renderAudioPage({
|
||||
audio: { id: "a1", storageKey: "audio/a1.mp3", articleTitle: "A", durationSec: 30 },
|
||||
accessDecision: { allowed: false, reason: "payment_required", creditsRequired: 3 },
|
||||
});
|
||||
|
||||
assert.match(html, /Unlock required: 3 credits/);
|
||||
});
|
||||
Reference in New Issue
Block a user