Files
memind/mindspace-cover-meta.test.mjs
T
John 2e14873f2d Initial commit: Memind H5 portal with MindSpace, Plaza, and agent jobs.
Track application source and tests; exclude local env, user workspaces, and runtime data via .gitignore.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-15 15:04:43 -07:00

22 lines
1.0 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { parseMindspaceCoverMeta, upsertMindspaceCoverMeta } from './mindspace-cover-meta.mjs';
test('upsertMindspaceCoverMeta replaces existing meta tag', () => {
const html = `<!doctype html><html><head>
<meta name="mindspace-cover" content='{"tag":"旧","emoji":"🌿"}'>
<title>Demo</title></head><body></body></html>`;
const next = upsertMindspaceCoverMeta(html, { tag: '旅行', emoji: '✈️', accent: '#eeb04e' });
const parsed = parseMindspaceCoverMeta(next);
assert.equal(parsed.tag, '旅行');
assert.equal(parsed.emoji, '✈️');
assert.equal(parsed.accent, '#eeb04e');
});
test('upsertMindspaceCoverMeta inserts meta into head when missing', () => {
const html = '<!doctype html><html><head><title>Demo</title></head><body></body></html>';
const next = upsertMindspaceCoverMeta(html, { tag: '美食', emoji: '🍜' });
assert.match(next, /name="mindspace-cover"/);
assert.equal(parseMindspaceCoverMeta(next).tag, '美食');
});