This commit is contained in:
2026-09-12 13:59:12 +08:00
commit 941ce4baab
71 changed files with 13037 additions and 0 deletions

31
test/theme-bg.test.js Normal file
View File

@@ -0,0 +1,31 @@
'use strict';
const assert = require('node:assert');
const { themeBgColor } = require('../config');
let passed = 0;
function check(name, fn) {
try { fn(); console.log(' ok -', name); passed++; }
catch (e) { console.error(' FAIL -', name, e.message); process.exitCode = 1; }
}
const expected = {
linear: '#0E0E12',
midnight: '#08090B',
carbon: '#1A1D23',
solarized: '#002B36',
github: '#0D1117',
light: '#FAFAFA',
};
for (const [theme, bg] of Object.entries(expected)) {
check(`themeBgColor('${theme}') === ${bg}`, () => {
assert.strictEqual(themeBgColor(theme), bg);
});
}
check('未知 theme 兜底为 light 背景', () => {
assert.strictEqual(themeBgColor('unknown'), '#FAFAFA');
assert.strictEqual(themeBgColor(''), '#FAFAFA');
assert.strictEqual(themeBgColor(null), '#FAFAFA');
});
console.log(`\n${passed} checks passed`);