47 lines
2.1 KiB
JavaScript
47 lines
2.1 KiB
JavaScript
'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('post list DOM follows the Zibll flex and multi-image contract', () => {
|
|
const markup = read('inc/helpers/posts-renderer/markup.php');
|
|
const data = read('inc/helpers/posts-renderer/post-data.php');
|
|
const cardStart = markup.indexOf('function aksrt_renderer_card');
|
|
const miniStart = markup.indexOf('function aksrt_renderer_mini');
|
|
const card = markup.slice(cardStart, miniStart);
|
|
|
|
assert.match(markup, /\['posts-item', 'list', 'ajax-item', 'flex'/);
|
|
assert.match(markup, /if \(!empty\(\$data\['is_mult_thumb'\]\)\)[\s\S]*?\$thumb = '';/);
|
|
assert.doesNotMatch(card, /item-excerpt|renderer_excerpt_markup/);
|
|
assert.match(data, /&& \$cfg\['mode'\] === 'list'/);
|
|
assert.match(data, /<a class=\"thumb-items contain\"/);
|
|
});
|
|
|
|
test('site shell has one float owner and fluid zones sit outside main', () => {
|
|
const layout = read('assets/css/frontend/layout.css');
|
|
const archive = read('inc/helpers/aksrt-archive.php');
|
|
const shell = layout.slice(layout.indexOf('Site shell'), layout.indexOf('页面标题区'));
|
|
|
|
assert.doesNotMatch(shell, /display:\s*grid/);
|
|
assert.match(shell, /width:\s*var\(--sidebar-width, 311px\)/);
|
|
assert.match(shell, /calc\(var\(--sidebar-width, 311px\) \+ 15px\)/);
|
|
assert.ok(archive.indexOf("$args['top_fluid']") < archive.indexOf('<main id="main-content"'));
|
|
assert.ok(archive.lastIndexOf("$args['bottom_fluid']") > archive.indexOf('</main>'));
|
|
});
|
|
|
|
test('widget shell uses Zibll wrappers without overriding post link colors', () => {
|
|
const renderer = read('src/WidgetSystem/FrontendRenderer.php');
|
|
const css = read('assets/widgets/frontend.css');
|
|
|
|
assert.match(renderer, /'zib-widget-wrap'/);
|
|
assert.match(renderer, /\$classes\[\] = 'zib-widget'/);
|
|
assert.match(renderer, /aksrt-widget__inner container/);
|
|
assert.doesNotMatch(css, /\.aksrt-widget a\s*\{[^}]*color:\s*inherit/);
|
|
assert.match(css, /\.aksrt-widget\.zib-widget\s*\{/);
|
|
});
|