Files
memind/plaza-seo.test.mjs
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

30 lines
1.0 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { createPlazaSeoService, seoInternals } from './plaza-seo.mjs';
test('normalizeUtm trims and caps length', () => {
assert.equal(seoInternals.normalizeUtm(' plaza '), 'plaza');
assert.equal(seoInternals.normalizeUtm('x'.repeat(120)).length, 100);
});
test('normalizeEventType accepts landing and signup', () => {
assert.equal(seoInternals.normalizeEventType('landing'), 'landing');
assert.throws(
() => seoInternals.normalizeEventType('click'),
(error) => error.code === 'invalid_input',
);
});
test('buildPostPublicUrl uses plaza path', () => {
assert.equal(
seoInternals.buildPostPublicUrl('abc-123', 'https://go.tkmind.cn'),
'https://go.tkmind.cn/plaza/p/abc-123',
);
});
test('pingBaidu skips when token missing', async () => {
const service = createPlazaSeoService(null, { baiduToken: '' });
const result = await service.pingBaidu(['https://go.tkmind.cn/plaza/p/1']);
assert.equal(result.pushed, false);
});