mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
b65df6b1e2
* fix(zsxq): separate content field from title, remove title truncation - Split getTopicText to return only title, add getTopicContent for body text - Remove .slice(0, 120) that was truncating titles - content field now contains full body text instead of duplicating title * fix(zsxq): preserve title fallback for body-only topics --------- Co-authored-by: huzekang <huzekang@opencode.ai> Co-authored-by: jackwener <jakevingoo@gmail.com>
32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
import { describe, expect, it } from 'vitest';
|
|
import { getTopicText, toTopicRow } from './utils.js';
|
|
|
|
describe('zsxq utils', () => {
|
|
it('keeps title and content separate when both fields exist', () => {
|
|
const topic = {
|
|
topic_id: '123',
|
|
title: 'A full title that should not be truncated',
|
|
talk: { text: 'This is the full body text.' },
|
|
};
|
|
|
|
expect(getTopicText(topic)).toBe('A full title that should not be truncated');
|
|
expect(toTopicRow(topic)).toMatchObject({
|
|
title: 'A full title that should not be truncated',
|
|
content: 'This is the full body text.',
|
|
});
|
|
});
|
|
|
|
it('falls back to body text for title when explicit title is absent', () => {
|
|
const topic = {
|
|
topic_id: '456',
|
|
talk: { text: 'Body-only topic text should still appear as the title preview.' },
|
|
};
|
|
|
|
expect(getTopicText(topic)).toBe('Body-only topic text should still appear as the title preview.');
|
|
expect(toTopicRow(topic)).toMatchObject({
|
|
title: 'Body-only topic text should still appear as the title preview.',
|
|
content: 'Body-only topic text should still appear as the title preview.',
|
|
});
|
|
});
|
|
});
|