import { describe, test, expect } from '@jest/globals';
import { execFileSync } from 'node:child_process';
import { resolve } from 'node:path';
// Use process.cwd() since tests run from project root
const cli = resolve(process.cwd(), 'dist/index.js');
describe('CLI generation', () => {
test('raw URL mode', () => {
const out = execFileSync(process.execPath, [cli, '--kind', 'chat-instructions', '--raw', 'https://raw.githubusercontent.com/github/awesome-copilot/main/instructions/markdown.instructions.md'], { encoding: 'utf8' });
expect(out).toContain('https://vscode.dev/redirect');
expect(out).toContain('VS_Code-Install-0098FF');
expect(out).toContain('VS_Code_Insiders-Install-24bfa5');
});
test('GitHub mode', () => {
const out2 = execFileSync(process.execPath, [cli, '--kind', 'chat-prompt', '--owner', 'github', '--repo', 'awesome-copilot', '--path', 'prompts/readme-blueprint-generator.prompt.md'], { encoding: 'utf8' });
expect(out2).toContain('https://vscode.dev/redirect');
expect(out2).toContain(encodeURIComponent('https://raw.githubusercontent.com/github/awesome-copilot/main/prompts/readme-blueprint-generator.prompt.md'));
});
});