mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(cli): add @videojs/cli docs command for LLM-friendly installation (#1214)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
9681515446
commit
24b8b77c8a
@@ -0,0 +1,65 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { replaceMarker } from '../replace.js';
|
||||
|
||||
describe('replaceMarker', () => {
|
||||
it('replaces content between markers', () => {
|
||||
const markdown = `# Title
|
||||
|
||||
<!-- cli:replace test -->
|
||||
old content here
|
||||
<!-- /cli:replace test -->
|
||||
|
||||
## Footer`;
|
||||
|
||||
const result = replaceMarker(markdown, 'test', 'new content');
|
||||
expect(result).toBe(`# Title
|
||||
|
||||
new content
|
||||
|
||||
## Footer`);
|
||||
});
|
||||
|
||||
it('returns unchanged markdown when marker not found', () => {
|
||||
const markdown = '# Title\n\nSome content';
|
||||
const result = replaceMarker(markdown, 'missing', 'replacement');
|
||||
expect(result).toBe(markdown);
|
||||
});
|
||||
|
||||
it('preserves content before and after markers', () => {
|
||||
const markdown = `before
|
||||
<!-- cli:replace id -->
|
||||
middle
|
||||
<!-- /cli:replace id -->
|
||||
after`;
|
||||
|
||||
const result = replaceMarker(markdown, 'id', 'replaced');
|
||||
expect(result).toContain('before');
|
||||
expect(result).toContain('after');
|
||||
expect(result).toContain('replaced');
|
||||
expect(result).not.toContain('middle');
|
||||
});
|
||||
|
||||
it('treats $ patterns in replacement literally', () => {
|
||||
const markdown = `start
|
||||
<!-- cli:replace test -->
|
||||
old
|
||||
<!-- /cli:replace test -->
|
||||
end`;
|
||||
|
||||
const result = replaceMarker(markdown, 'test', 'https://example.com/video.php?id=$1&ref=$&');
|
||||
expect(result).toContain('https://example.com/video.php?id=$1&ref=$&');
|
||||
});
|
||||
|
||||
it('handles multiline content between markers', () => {
|
||||
const markdown = `start
|
||||
<!-- cli:replace multi -->
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
<!-- /cli:replace multi -->
|
||||
end`;
|
||||
|
||||
const result = replaceMarker(markdown, 'multi', 'single line');
|
||||
expect(result).toBe('start\nsingle line\nend');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user