mirror of
https://github.com/zoriya/v10.git
synced 2026-08-09 23:58:06 +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,54 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { InstallationOptions } from '@/utils/installation/codegen';
|
||||
import { formatInstallationCode } from '../format.js';
|
||||
|
||||
const baseHTML: InstallationOptions = {
|
||||
framework: 'html',
|
||||
useCase: 'default-video',
|
||||
skin: 'video',
|
||||
renderer: 'html5-video',
|
||||
sourceUrl: '',
|
||||
installMethod: 'npm',
|
||||
};
|
||||
|
||||
const baseReact: InstallationOptions = {
|
||||
framework: 'react',
|
||||
useCase: 'default-video',
|
||||
skin: 'video',
|
||||
renderer: 'html5-video',
|
||||
sourceUrl: '',
|
||||
installMethod: 'npm',
|
||||
};
|
||||
|
||||
describe('formatInstallationCode', () => {
|
||||
it('formats HTML + npm with install, JS imports, and HTML sections', () => {
|
||||
const result = formatInstallationCode(baseHTML);
|
||||
expect(result).toContain('## Install Video.js');
|
||||
expect(result).toContain('npm install @videojs/html');
|
||||
expect(result).toContain('## JavaScript imports');
|
||||
expect(result).toContain('## HTML');
|
||||
expect(result).toContain('<video-player>');
|
||||
});
|
||||
|
||||
it('formats HTML + CDN without JS imports section', () => {
|
||||
const result = formatInstallationCode({ ...baseHTML, installMethod: 'cdn' });
|
||||
expect(result).toContain('## Install Video.js');
|
||||
expect(result).toContain('<script');
|
||||
expect(result).not.toContain('## JavaScript imports');
|
||||
expect(result).toContain('## HTML');
|
||||
});
|
||||
|
||||
it('formats React with install, create, and use sections', () => {
|
||||
const result = formatInstallationCode(baseReact);
|
||||
expect(result).toContain('## Install Video.js');
|
||||
expect(result).toContain('npm install @videojs/react');
|
||||
expect(result).toContain('## Create your player');
|
||||
expect(result).toContain('MyPlayer');
|
||||
expect(result).toContain('## Use your player');
|
||||
});
|
||||
|
||||
it('uses pnpm install command when specified', () => {
|
||||
const result = formatInstallationCode({ ...baseReact, installMethod: 'pnpm' });
|
||||
expect(result).toContain('pnpm add @videojs/react');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user