A bit of JS to improve the UX slightly... More tests. Everything is kosher now.
Some checks failed
ci/woodpecker/push/ci Pipeline failed
ci/woodpecker/push/deploy unknown status

This commit is contained in:
2026-02-01 19:01:12 -03:00
parent 3a940e9da1
commit dfa18c8560
9 changed files with 682 additions and 6 deletions

View File

@@ -0,0 +1,44 @@
/**
* @vitest-environment jsdom
*/
import { readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
const __dirname = dirname(fileURLToPath(import.meta.url));
const SCRIPT_PATH = join(__dirname, '../../static/assets/js/copyright-year.js');
describe('copyright-year.js', () => {
let el: HTMLSpanElement;
beforeEach(() => {
el = document.createElement('span');
el.id = 'copyright-year';
el.textContent = 'placeholder';
document.body.appendChild(el);
});
afterEach(() => {
el.remove();
});
it('sets #copyright-year textContent to current year when element exists', () => {
const code = readFileSync(SCRIPT_PATH, 'utf8');
eval(code);
const expected = new Date().getFullYear().toString();
expect(el.textContent).toBe(expected);
});
it('does not throw when #copyright-year is missing', () => {
el.remove();
const code = readFileSync(SCRIPT_PATH, 'utf8');
expect(() => {
eval(code);
}).not.toThrow();
});
});