30 lines
747 B
TypeScript
30 lines
747 B
TypeScript
import {describe, expect, it} from 'vitest';
|
|
|
|
import {parseJsonResponseText, parseLineListContent} from './llmParsers';
|
|
|
|
describe('llmParsers', () => {
|
|
it('parses fenced json payloads', () => {
|
|
expect(
|
|
parseJsonResponseText('```json\n{"storyText":"hello","options":[]}\n```'),
|
|
).toEqual({
|
|
storyText: 'hello',
|
|
options: [],
|
|
});
|
|
});
|
|
|
|
it('parses embedded json objects', () => {
|
|
expect(
|
|
parseJsonResponseText('prefix {"storyText":"hello","options":[]} suffix'),
|
|
).toEqual({
|
|
storyText: 'hello',
|
|
options: [],
|
|
});
|
|
});
|
|
|
|
it('extracts compact suggestion lines', () => {
|
|
expect(
|
|
parseLineListContent('- first\n2. second\nthird', 2),
|
|
).toEqual(['first', 'second']);
|
|
});
|
|
});
|