update
This commit is contained in:
31
test/theme-bg.test.js
Normal file
31
test/theme-bg.test.js
Normal 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`);
|
||||
Reference in New Issue
Block a user