const { execSync } = require('child_process');
const path = require('path');

describe('CLI', () => {
  const cliPath = path.join(__dirname, 'index.js');

  function runCli(args = '') {
    try {
      execSync(`node ${cliPath} ${args}`, { encoding: 'utf-8', stdio: 'pipe' });
      return { stdout: '', stderr: '' };
    } catch (err) {
      return {
        stdout: err.stdout ? err.stdout.toString() : '',
        stderr: err.stderr ? err.stderr.toString() : ''
      };
    }
  }

  it('should fail if required parameters are missing', () => {
    const { stdout, stderr } = runCli();
    const output = stdout + stderr;
    expect(output).toMatch(/host_url/);
    expect(output).toMatch(/token/);
  });

  it('should print host_url and token', () => {
    const { stdout, stderr } = runCli('--host_url http://localhost --token testtoken');
    const output = stdout + stderr;
    expect(output).toMatch(/Host URL: http:\/\/localhost/);
    expect(output).toMatch(/Token: testtoken/);
  });

  // More tests can be added with API mocking
}); 