项目文件夹

文件
wehub-resource-sync 2771cff92b
CI / lint (push) Failing after 1s
CI / typecheck (push) Failing after 2s
CI / test (push) Failing after 1s
CI / build (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:22:56 +08:00

36 行
1.3 KiB
TypeScript

import { appendMarkdownSnippet } from '@/utils/markdown';
describe('appendMarkdownSnippet', () => {
it('returns existing prompt when snippet is empty', () => {
expect(appendMarkdownSnippet('Hello', '')).toBe('Hello');
});
it('returns existing prompt when snippet is whitespace only', () => {
expect(appendMarkdownSnippet('Hello', ' \n ')).toBe('Hello');
});
it('returns trimmed snippet when existing prompt is empty', () => {
expect(appendMarkdownSnippet('', ' Hello ')).toBe('Hello');
});
it('returns trimmed snippet when existing prompt is whitespace only', () => {
expect(appendMarkdownSnippet(' ', ' Hello ')).toBe('Hello');
});
it('adds double newline separator when prompt does not end with newline', () => {
expect(appendMarkdownSnippet('First', 'Second')).toBe('First\n\nSecond');
});
it('adds single newline when prompt ends with one newline', () => {
expect(appendMarkdownSnippet('First\n', 'Second')).toBe('First\n\nSecond');
});
it('adds no separator when prompt ends with double newline', () => {
expect(appendMarkdownSnippet('First\n\n', 'Second')).toBe('First\n\nSecond');
});
it('trims the snippet before appending', () => {
expect(appendMarkdownSnippet('First', ' Second ')).toBe('First\n\nSecond');
});
});