'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const test = require('node:test');
const root = path.resolve(__dirname, '..', '..');
const read = (file) => fs.readFileSync(path.join(root, file), 'utf8');
test('icon card renderers keep vertical and horizontal legacy DOM contracts separate', () => {
const helper = read('inc/helpers/aksrt-icon-cards.php');
const widgets = read('src/WidgetSystem/Renderers/GeneralRenderer.php');
const header = read('inc/helpers/homepage/header-components.php');
assert.match(helper, /
\$card\['customize_icon'\] \?\? ''/);
assert.doesNotMatch(widgets, /\$card\['custom_icon'\]/);
assert.doesNotMatch(widgets, /\$card\['icon_image'\]/);
assert.doesNotMatch(widgets, /\$card\['description'\]/);
assert.match(header, /empty\(\$card\['custom_icon'\]\)/);
});
test('homepage horizontal cards render fully from legacy CSS with no dedicated stylesheet', () => {
const baseCss = read('assets/css/frontend/base.css');
const widgetCss = read('assets/widgets/frontend.css');
const scripts = read('src/Core/ScriptsPart1b.php');
assert.equal(fs.existsSync(path.join(root, 'assets/css/frontend/header-cards.css')), false);
assert.doesNotMatch(baseCss, /\.icon-cover-card\.aksrt-icon-cover-card/);
assert.doesNotMatch(baseCss, /\.header-components-card/);
assert.match(
baseCss,
/\.header-slider-card\s+\.icon-cover-card\s*\{[^}]*font-size:\s*12px/s,
);
assert.doesNotMatch(scripts, /header-cards/);
assert.doesNotMatch(widgetCss, /aksrt-widget-icon-cards \.icon-cover-card/);
});
test('header icon-card defaults use bundled Font Awesome icons', () => {
const defaults = [
read('src/Admin/Schema/SchemaPageDisplay.php'),
read('src/Admin/PageConfigMetaBox.php'),
read('src/Settings/DisplayPageGroups.php'),
];
for (const source of defaults) {
assert.doesNotMatch(source, /'icon'\s*=>\s*'zibsvg-/);
for (const icon of ['gem', 'star', 'fire', 'wrench']) {
assert.match(source, new RegExp(`'icon'\\s*=>\\s*'fa fas fa-${icon}'`));
}
}
});