const assert = require("node:assert/strict"); const fs = require("node:fs"); const path = require("node:path"); const appBarSource = fs.readFileSync( path.join(__dirname, "../../src/components/app-bar/index.tsx"), "utf8" ); const appBarStyles = fs.readFileSync( path.join(__dirname, "../../src/components/app-bar/index.scss"), "utf8" ); function run(name, fn) { try { fn(); console.log(`PASS ${name}`); } catch (error) { console.error(`FAIL ${name}`); throw error; } } run("AppBar back action uses the shared back.svg asset", () => { assert.match(appBarSource, /back\.svg/); assert.match(appBarSource, / { assert.doesNotMatch(appBarSource, /<|>\s*<\s* { assert.match(appBarStyles, /\.app-bar__back-icon\s*\{[\s\S]*width:\s*32rpx;/); assert.match(appBarStyles, /\.app-bar__back-icon\s*\{[\s\S]*height:\s*32rpx;/); }); run("AppBar exposes fixed layout modes instead of scattered slot props", () => { assert.match(appBarSource, /type AppBarMode = "spacer" \| "back-title" \| "back-title-actions-below" \| "title-actions-below"/); assert.match(appBarSource, /mode\?: AppBarMode/); assert.match(appBarSource, /actions\?: ReactNode/); assert.doesNotMatch(appBarSource, /subtitle\?:|eyebrow\?:|align\?:|rightText\?:|onRightAction\?:|leftSlot\?:|rightSlot\?:|bottomSlot\?:/); }); run("AppBar includes dedicated rows for title and below-line actions", () => { assert.match(appBarSource, /app-bar__title-row/); assert.match(appBarSource, /app-bar__actions-row/); assert.match(appBarStyles, /\.app-bar__actions-row\s*\{/); assert.match(appBarStyles, /\.app-bar__title-row\s*\{/); });