35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
"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/);
|
|
assert.match(html, /manifest.webmanifest/);
|
|
});
|
|
|
|
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/);
|
|
});
|